Skip to content

Commit

Permalink
Systemwide: rename flags nuggits
Browse files Browse the repository at this point in the history
This is more on brand
  • Loading branch information
miallo committed Jan 7, 2024
1 parent a93428e commit 6fb02b6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
10 changes: 5 additions & 5 deletions create_challenge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cp "$DOCDIR/04_branch/branch.md" .
git add branch.md
commit -m "WIP: add description on branches
Flag: ShowMeMore"
nuggit: ShowMeMore"
# For reference in commit.md later
BRANCH_COMMIT="$(git rev-parse --short @)"

Expand Down Expand Up @@ -61,8 +61,8 @@ cp "$DOCDIR/08_tags/tags.md" .
git add tags.md
commit -m 'Add description on tags
Flag: LogCat'
git tag -a the-first-tag -m "Flag: AnnotateMeIfYouCan"
nuggit: LogCat'
git tag -a the-first-tag -m "nuggit: AnnotateMeIfYouCan"

git switch main -c history
cp "$DOCDIR/06_log/log.md" .
Expand All @@ -74,9 +74,9 @@ git switch main
# uncommitted changes/status
# Needs to be second to last (only before hooks), so that the uncommitted changes are available initially
cat "$DOCDIR/02_status_diff/status.md" >> README.md
UNSTAGED_FLAG='Flag: WorkInProgress'
UNSTAGED_FLAG='nuggit: WorkInProgress'
STAGING_DIFF_DESCRIPTION='For seeing what would be committed next you can run `git diff --staged`. A synonym for "--staged" that you might see in some places is "--cached".'
STAGING_FLAG='Flag: CommitmentIssues'
STAGING_FLAG='nuggit: CommitmentIssues'
COMMIT_DESCRIPTION='To commit all changes in the staging area you can run `git commit` and an editor will open where you can type a commit message. Further information can be found in "commit.md"'
{
echo "$UNSTAGED_FLAG"
Expand Down
2 changes: 1 addition & 1 deletion src/hook_preamble.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Flag: LocalCodeExecution
# nuggit: LocalCodeExecution
# Congrats on finding this! This flag is gonna destroy itself when any of the hooks are executed ;)
shopt -s extglob
ROOT="$(git rev-parse --show-toplevel)"
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ IS_SWITCH="$3"

# switched to my-new-branch
if [ "$(git rev-parse --abbrev-ref HEAD)" = "my-new-branch" ] && [ "$IS_SWITCH" = 1 ]; then
echo "Flag: MyFirstBranch"
echo "nuggit: MyFirstBranch"
exit
fi

# switched to branches-explained
if [ "$NEXT_REF" = "$(git rev-parse branches-explained)" ] && [ "$IS_SWITCH" = 1 ]; then
echo "Flag: Switcheridoo"
echo "nuggit: Switcheridoo"
exit
fi
5 changes: 4 additions & 1 deletion src/hooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ COMMIT_SOURCE=$2
SHA1=$3

# add a flag to the commit message
git interpret-trailers --in-place --trailer "Flag: CommitMirInsAbendteuerland" "$COMMIT_MSG_FILE"
git interpret-trailers --in-place \
--trailer "This is the challenge nuggit speaking. Please don't mind me. I am injecting myself in a few places (like this one), so if you ever see anything starting with nuggit in this repo, I injected it and it usually wouldn't be there in a normal git repo." \
--trailer "nuggit: CommitMirInsAbendteuerland" \
"$COMMIT_MSG_FILE"
if test -z "$COMMIT_SOURCE"
then
/usr/bin/env perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
Expand Down
22 changes: 11 additions & 11 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,49 @@ echo "Running tests..."
cd challenge

it 'LocalCodeExecution flag in hooks' '
expect "cat .git/hooks/*" to contain "Flag: LocalCodeExecution"
expect "cat .git/hooks/*" to contain "nuggit: LocalCodeExecution"
'

it 'WorkInProgress in diff' '
expect "git diff" to contain "Flag: WorkInProgress"
expect "git diff" to contain "nuggit: WorkInProgress"
'

it 'CommitmentIssues in diff --staged' '
expect "git diff --staged" to contain "Flag: CommitmentIssues"
expect "git diff --staged" to contain "nuggit: CommitmentIssues"
'

it 'CommitMirInsAbendteuerland in new commit message' '
git commit -m "My first commit" --quiet
expect "git show" to contain "Flag: CommitMirInsAbendteuerland"
expect "git show" to contain "nuggit: CommitMirInsAbendteuerland"
'

it 'LocalCodeExecution flag should be deleted after execution of any hook (in this case the commit)' '
expect "cat .git/hooks/*" not to contain "Flag: LocalCodeExecution"
expect "cat .git/hooks/*" not to contain "nuggit: LocalCodeExecution"
'

it 'restore should not show Switcheridoo flag' '
expect "git restore README.md 2>&1" not to contain "Flag: Switcheridoo"
expect "git restore README.md 2>&1" not to contain "nuggit: Switcheridoo"
'

it 'ShowMeMore in branch commit' <<EOF
expect 'eval "\$(get_sh_codeblock commit.md)"' to contain "Flag: ShowMeMore"
expect 'eval "\$(get_sh_codeblock commit.md)"' to contain "nuggit: ShowMeMore"
EOF

it 'Switcheridoo when switching to "branches-explained"' '
expect "git switch branches-explained 2>&1" to contain "Flag: Switcheridoo"
expect "git switch branches-explained 2>&1" to contain "nuggit: Switcheridoo"
'

it 'MyFirstBranch when creating' '
expect "git switch -c my-new-branch 2>&1" to contain "Flag: MyFirstBranch"
expect "git switch -c my-new-branch 2>&1" to contain "nuggit: MyFirstBranch"
git switch history -q
'

it 'LogCat for log' <<EOF
expect 'eval "\$(get_sh_codeblock log.md)"' to contain "Flag: LogCat"
expect 'eval "\$(get_sh_codeblock log.md)"' to contain "nuggit: LogCat"
EOF

it 'AnnotateMeIfYouCan in annotated tag' '
expect "git show the-first-tag" to contain "Flag: AnnotateMeIfYouCan"
expect "git show the-first-tag" to contain "nuggit: AnnotateMeIfYouCan"
git switch --detach -q the-first-tag
'

Expand Down

0 comments on commit 6fb02b6

Please sign in to comment.