Skip to content

Commit 9159e2a

Browse files
committed
New feat: verify gpg signature on commits, merge, tag
1 parent af48877 commit 9159e2a

File tree

4 files changed

+42
-16
lines changed

4 files changed

+42
-16
lines changed

.bashlava_env.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ CFG_USER_IS="${USER}"
2323
CFG_EDGE_EXTENTED="false" # not coded yet
2424
CFG_LOG_LINE_NBR_SHORT="4" # log() default line number
2525
CFG_LOG_LINE_NBR_LONG="12" # log() default line number
26+
CFG_TAG_ARE_SIGNED="false"
2627
CFG_RELEASE_POPUP="false" # not coded yet
2728

2829
CFG_TEST_SHOW_VARS="false" # test extension

.bashlava_env_override.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ APP_NAME="bashlava"
77
GITHUB_USER="firepress-org"
88
APP_VERSION="1.47.0"
99

10-
CFG_USE_PRIVATE_DIRECTORY="true"
10+
CFG_USE_PRIVATE_DIRECTORY="true"
11+
CFG_TAG_ARE_SIGNED="true"

bashlava.sh

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ PRIORITY 1 _____________________________________________________________________
2323
2424
2525
TODO
26-
## New feat: gc() one core fct + 5 childs to use git-crypt
27-
- gc h(), add /docs/help_gitcrypt.md
28-
- (h) update /docs/help.md
26+
New feat: verify gpg signature on commits, merge, tag
27+
- Add config: CFG_TAG_ARE_SIGNED
28+
- update dummy()
29+
- update commit()
30+
- in ~/.gitconfig
31+
- signingKey = 466798446A36CC66A9AA58BEBEF00F535005628E
32+
- gpgsign = true
2933
- Impact on: #4, #8
3034
31-
## Minor
32-
- Update README.md
33-
3435
TODO
3536
gc()
3637
CONFIG: is if key is: symetric OR pub/priv
@@ -221,7 +222,19 @@ function commit { # User_
221222
Condition_Attr_2_Must_Be_Provided
222223
_from_fct="c"
223224

224-
git status && git add -A && git commit -m "${input_2}" && git push
225+
git status && git add -A
226+
227+
if [[ "${CFG_TAG_ARE_SIGNED}" == "true" ]]; then
228+
git commit -S -m "${input_2}"
229+
echo "WIP commit should be signed"
230+
elif [[ "${CFG_TAG_ARE_SIGNED}" == "false" ]]; then
231+
git commit -m "${input_2}"
232+
echo "WIP commit is NOT signed"
233+
else
234+
my_message="FATAL: tag" && Print_Fatal
235+
fi
236+
237+
git push
225238

226239
Show_What_Was_Done
227240
git --no-pager log --decorate=short --pretty=oneline --abbrev-commit -n"${CFG_LOG_LINE_NBR_SHORT}"
@@ -353,7 +366,16 @@ function tag { # User_
353366
#Condition_Attr_2_Must_Be_Empty
354367
_from_fct="t"
355368

356-
git tag ${APP_VERSION} && git push --tags && echo
369+
if [[ "${CFG_TAG_ARE_SIGNED}" == "true" ]]; then
370+
git tag -s "${APP_VERSION}" -m "tag: {APP_VERSION} using bashlava"
371+
elif [[ "${CFG_TAG_ARE_SIGNED}" == "false" ]]; then
372+
git tag "${APP_VERSION}"
373+
else
374+
my_message="FATAL: tag" && Print_Fatal
375+
fi
376+
377+
git push --tags
378+
echo
357379
Show_Version
358380
Show_Tag
359381

@@ -473,10 +495,10 @@ function dummy { # User_
473495
_from_fct="d"
474496
_in_file="./docs/DUMMY.md"
475497

476-
# create a commit X time the update
498+
# create two commits in a row
477499
for lineID in $(seq 1 2); do
478500
date_nano="$(date +%Y-%m-%d_%HH%Ms%S-%N)"
479-
_hash=$(echo ${date_nano} | sha256sum | awk '{print $1}')
501+
_hash=$(echo "${date_nano} ${lineID}" | sha256sum | awk '{print $1}')
480502
_hash_four_last="${_hash: -4}"
481503
echo "Dummy Commit ${lineID} - $(date +%Y-%m-%d_%HH%M_%S) - ${_hash}" >> "${_in_file}"
482504
git add -A && git commit -m "Dummy Commit ${lineID} - ${_hash_four_last}"

docs/help_gitcrypt.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ You should use public/private keys which is much more secure.
131131

132132
## As a USER_DEV
133133

134-
As a USER_DEV must create a key
135-
`gpg --gen-key`
136-
137134
As a USER_DEV, check the gpg keys
138135
`gpg --list-keys`
139136

137+
As a USER_DEV must create a key
138+
`gpg --gen-key`
139+
140140
As a USER_DEV, check the gpg keys and list the keys and copy the key ID (KEY_ID ex: 9F9VD135y67289ACGGD349E8S345TSRY4ECC53):
141141

142142
`gpg --list-keys`
@@ -184,8 +184,8 @@ Symetric steup: It's a good idea to have ../git-crypt-key as an absolut path to
184184
export/backup your keys:
185185

186186
```
187-
gpg --output public.pgp --armor --export [email protected]
188-
gpg --output private.pgp --armor --export-secret-key [email protected]
187+
gpg --output public.pgp --armor --export [email protected]
188+
gpg --output private.pgp --armor --export-secret-key [email protected]
189189
```
190190

191191
source: https://unix.stackexchange.com/a/482559
@@ -195,6 +195,8 @@ source: https://unix.stackexchange.com/a/482559
195195
- https://hackernoon.com/things-you-must-know-about-git-crypt-to-successfully-protect-your-secret-data-kyi3wi6
196196
- https://buddy.works/guides/git-crypt
197197
- https://medium.com/@ahmed.kamel/git-crypt-unattended-unlock-with-gpg-passphrase-in-docker-f0aa39b85a
198+
- manage gpg key to sign commits on github - https://www.youtube.com/watch?v=4166ExAnxmo
199+
- code ~/.gitconfig
198200

199201
## What is great
200202

0 commit comments

Comments
 (0)