| | | |
Offset 1015, 115 lines modified | Offset 1015, 75 lines modified |
1015 | ··local·commands="add|changes|clean|hide|init|killperson|list|remove|reveal|tell|usage|whoknows" | 1015 | ··local·commands="add|changes|clean|hide|init|killperson|list|remove|reveal|tell|usage|whoknows" |
| |
1016 | ··echo·"usage:·git·secret·[$commands]" | 1016 | ··echo·"usage:·git·secret·[$commands]" |
1017 | } | 1017 | } |
1018 | #!/usr/bin/env·bash | 1018 | #!/usr/bin/env·bash |
| |
| |
1019 | function·clean·{ | 1019 | function·killperson·{ |
1020 | ··local·verbose='' | |
| |
1021 | ··OPTIND=1 | 1020 | ··OPTIND=1 |
| |
1022 | ··while·getopts·'vh'·opt;·do | 1021 | ··while·getopts·'h'·opt;·do |
1023 | ····case·"$opt"·in | 1022 | ····case·"$opt"·in |
1024 | ······v)·verbose="v";; | 1023 | ······h)·_show_manual_for·'killperson';; |
| |
1025 | ······h)·_show_manual_for·'clean';; | |
| |
1026 | ······*)·_invalid_option_for·'clean';; | 1024 | ······*)·_invalid_option_for·'killperson';; |
1027 | ····esac | 1025 | ····esac |
1028 | ··done | 1026 | ··done |
| |
1029 | ··shift·$((OPTIND-1)) | 1027 | ··shift·$((OPTIND-1)) |
1030 | ··[·"$1"·=·'--'·]·&&·shift | 1028 | ··[·"$1"·=·"--"·]·&&·shift |
| |
1031 | ··_user_required | 1029 | ··_user_required |
| |
1032 | ··#·User·should·see·properly·formated·output: | 1030 | ··#·Command·logic: |
1033 | ··_find_and_clean_formated·"*$SECRETS_EXTENSION"·"$verbose" | |
1034 | } | |
1035 | #!/usr/bin/env·bash | |
| |
1036 | #·shellcheck·disable=2016 | 1031 | ··local·emails=(·"$@"·) |
1037 | AWK_ADD_TO_GITIGNORE=' | |
1038 | BEGIN·{ | |
1039 | ··cnt=0 | |
1040 | } | |
| |
1041 | function·check_print_line(line){ | 1032 | ··if·[[·${#emails[@]}·-eq·0·]];·then |
1042 | ··if·(line·==·pattern)·{ | 1033 | ····_abort·"at·least·one·email·is·required." |
1043 | ····cnt++ | 1034 | ··fi |
1044 | ··} | |
1045 | ··print·line | |
1046 | } | |
| |
1047 | #·main·function | 1035 | ··#·Getting·the·local·`gpg`·command: |
1048 | { | 1036 | ··local·gpg_local |
1049 | ··check_print_line($0)······#·check·and·print·first·line | 1037 | ··gpg_local=$(_get_gpg_local) |
1050 | ··while·(getline·==·1)·{····#·check·and·print·all·other | |
1051 | ····check_print_line($0) | |
1052 | ··} | |
1053 | } | |
| |
1054 | END·{ | 1038 | ··for·email·in·"${emails[@]}";·do |
1055 | ··if·(·cnt·==·0)·{·········#·if·file·did·not·contain·pattern·add | 1039 | ····$gpg_local·--batch·--yes·--delete-key·"$email" |
1056 | ····print·pattern | 1040 | ··done |
1057 | ··} | |
1058 | } | |
1059 | ' | |
| |
1060 | function·gitignore_add_pattern·{ | 1041 | ··echo·'removed·keys.' |
1061 | ··local·pattern | 1042 | ··echo·"now·[$*]·do·not·have·an·access·to·the·repository." |
1062 | ··local·gitignore_file_path | 1043 | ··echo·'make·sure·to·hide·the·existing·secrets·again.' |
| 1044 | } |
| 1045 | #!/usr/bin/env·bash |
| |
1063 | ··pattern="$1" | |
1064 | ··gitignore_file_path=$(_append_root_path·'.gitignore') | |
| |
1065 | ··_maybe_create_gitignore | 1046 | function·clean·{ |
1066 | ··_gawk_inplace·-v·pattern="$pattern"·"'$AWK_ADD_TO_GITIGNORE'"·"$gitignore_file_path" | 1047 | ··local·verbose='' |
1067 | } | |
| |
1068 | function·init·{ | |
1069 | ··OPTIND=1 | 1048 | ··OPTIND=1 |
| |
1070 | ··while·getopts·'h'·opt;·do | 1049 | ··while·getopts·'vh'·opt;·do |
1071 | ····case·"$opt"·in | 1050 | ····case·"$opt"·in |
1072 | ······h)·_show_manual_for·'init';; | 1051 | ······v)·verbose="v";; |
| |
1073 | ······*)·_invalid_option_for·'init';; | 1052 | ······h)·_show_manual_for·'clean';; |
| |
| 1053 | ······*)·_invalid_option_for·'clean';; |
1074 | ····esac | 1054 | ····esac |
1075 | ··done | 1055 | ··done |
| |
1076 | ··shift·$((OPTIND-1)) | 1056 | ··shift·$((OPTIND-1)) |
1077 | ··[·"$1"·=·'--'·]·&&·shift | 1057 | ··[·"$1"·=·'--'·]·&&·shift |
| |
1078 | ··#·Check·if·'.gitsecret/'·already·exists: | 1058 | ··_user_required |
1079 | ··local·git_secret_dir | |
1080 | ··git_secret_dir=$(_get_secrets_dir) | |
| |
1081 | ··if·[[·-d·"$git_secret_dir"·]];·then | |
1082 | ····_abort·'already·inited.' | |
1083 | ··fi | |
| |
1084 | ··#·Check·if·it·is·ignored: | |
1085 | ··_secrets_dir_is_not_ignored | |
| |
1086 | ··#·Create·internal·files: | |
| |
1087 | ··mkdir·"$git_secret_dir"·"$(_get_secrets_dir_keys)"·"$(_get_secrets_dir_path)" | |
1088 | ··touch·"$(_get_secrets_dir_keys_mapping)"·"$(_get_secrets_dir_paths_mapping)" | |
| |
1089 | ··echo·"'$git_secret_dir/'·created." | |
| |
1090 | ··local·random_seed_file | |
1091 | ··random_seed_file=".gitsecret/keys/random_seed" | |
1092 | ··gitignore_add_pattern·"$random_seed_file" | |
| |
1093 | ··#·TODO:·git·attributes·to·view·diffs | 1059 | ··#·User·should·see·properly·formated·output: |
| 1060 | ··_find_and_clean_formated·"*$SECRETS_EXTENSION"·"$verbose" |
1094 | } | 1061 | } |
1095 | #!/usr/bin/env·bash | 1062 | #!/usr/bin/env·bash |
| |
| |
1096 | function·remove·{ | 1063 | function·remove·{ |
1097 | ··local·clean=0 | 1064 | ··local·clean=0 |
| |
Offset 1208, 50 lines modified | Offset 1168, 90 lines modified |
| |
1208 | ··#·Getting·the·users·from·gpg: | 1168 | ··#·Getting·the·users·from·gpg: |
1209 | ··keys=$(_get_users_in_keyring) | 1169 | ··keys=$(_get_users_in_keyring) |
1210 | ··echo·"$keys" | 1170 | ··echo·"$keys" |
1211 | } | 1171 | } |
1212 | #!/usr/bin/env·bash | 1172 | #!/usr/bin/env·bash |
Max diff block lines reached; 2288/5658 bytes (40.44%) of diff not shown.
|