github.com/StackExchange/blackbox/v2@v2.0.1-0.20220331193400-d84e904973ab/bin/blackbox_initialize (about) 1 #!/usr/bin/env bash 2 3 # 4 # blackbox_initialize -- Enable blackbox for a GIT or HG repo. 5 # 6 # 7 # Example: 8 # blackbox_initialize 9 # 10 11 set -e 12 source "${0%/*}/_blackbox_common.sh" 13 14 if [[ $1 != 'yes' ]]; then 15 read -r -p "Enable blackbox for this $VCS_TYPE repo? (yes/no) " ans 16 if [[ $ans = 'no' || $ans = 'n' || $ans = '' ]]; then 17 echo 'Exiting...' 18 exit 1 19 fi 20 fi 21 22 if [[ $VCS_TYPE = "unknown" ]]; then 23 echo 'Not in a known VCS directory' 24 exit 1 25 fi 26 27 change_to_vcs_root 28 29 echo VCS_TYPE: $VCS_TYPE 30 vcs_ignore "${BLACKBOXDATA}/pubring.gpg~" "${BLACKBOXDATA}/pubring.kbx~" "${BLACKBOXDATA}/secring.gpg" 31 32 # Make directories 33 mkdir -p "${KEYRINGDIR}" 34 vcs_add "${KEYRINGDIR}" 35 touch "$BLACKBOXDATA/$BB_ADMINS_FILE" "$BLACKBOXDATA/$BB_FILES_FILE" 36 vcs_add "$BLACKBOXDATA/$BB_ADMINS_FILE" "$BLACKBOXDATA/$BB_FILES_FILE" 37 38 if [[ $VCS_TYPE = "git" ]]; then 39 40 # Set .gitattributes so that Windows users don't break the admin files. 41 FILE="$BLACKBOXDATA/.gitattributes" 42 touch "$FILE" 43 LINE='blackbox-admins.txt text eol=lf' 44 grep -qF "$LINE" "$FILE" || echo "$LINE" >> "$FILE" 45 LINE='blackbox-files.txt text eol=lf' 46 grep -qF "$LINE" "$FILE" || echo "$LINE" >> "$FILE" 47 vcs_add "$FILE" 48 fi 49 50 if [[ $VCS_TYPE = "svn" ]]; then 51 echo 52 echo 53 echo '`subversion` automatically tracks the ignored files; you just need to commit.' 54 else 55 IGNOREFILE="$(vcs_ignore_file_path)" 56 test -f "$IGNOREFILE" && vcs_add "$IGNOREFILE" 57 58 # Make a suggestion: 59 echo 60 echo 61 echo 'NEXT STEP: You need to manually check these in:' 62 echo ' ' $VCS_TYPE commit -m\'INITIALIZE BLACKBOX\' "$BLACKBOXDATA" "$IGNOREFILE" 63 fi