this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Error improvements for git-identity

+39 -5
+39 -5
bin/git-identity
··· 3 3 set -eo pipefail 4 4 5 5 USAGE=$(cat <<EOF 6 - [-d|--define] <identity> <name> <email> 6 + | [-d|--define] <identity> <name> <email> 7 7 | [-p|--print] <identity> 8 8 | [-r|--remove] <identity> 9 9 | [-l|--list] 10 10 | [-R|--list-raw] 11 11 | [-h|--help] 12 12 | <identity> 13 + 14 + Define identity globally: 15 + git -d private "My Name Suername" me@example.com 16 + git -d company "My Name Suername" me@your-company.com 17 + 18 + Use identity in your git repository: 19 + cd your_repository 20 + git identity private 21 + 22 + List current identity: 23 + cd your_repository 24 + git identity private 25 + 26 + Print current identity: 27 + cd your_repository 28 + git identity 29 + 13 30 EOF) 14 31 32 + error () { 33 + local message="$1" 34 + (>&2 echo "$message") 35 + exit 1 36 + } 37 + 15 38 lookup () { 16 39 local identity="$1" 17 40 local key="$2" 18 41 19 - git config "identity.$identity.$key" 42 + git config "identity.$identity.$key" || error "Unknown identity: $identity" 20 43 } 21 44 22 45 format_identity () { ··· 72 95 print_current_identity () { 73 96 local identity 74 97 75 - identity="$(git config user.identity)" 76 - 77 - echo "Current identity: $(format_identity "$identity")" 98 + identity="$(git config user.identity || echo "")" 99 + if [ "$identity" ]; then 100 + echo "Current identity: $(format_identity "$identity")" 101 + else 102 + (>&2 echo "=================================================") 103 + (>&2 echo -e "\033[0;31mNO IDENTITY SET\033[0m") 104 + (>&2 echo "Your name: $(git config user.name)") 105 + (>&2 echo "Your email: $(git config user.email)") 106 + (>&2 echo "=================================================") 107 + (>&2 echo "How to use this tool") 108 + (>&2 echo "${USAGE}") 109 + (>&2 echo "=================================================") 110 + exit 1 111 + fi 78 112 } 79 113 80 114 define_identity () {