Created
March 10, 2021 17:06
-
-
Save dannysauer/e0dd0f738d79362e5b1a70cd58ac570c to your computer and use it in GitHub Desktop.
git tag promotion aliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✔ /tmp/testrepo [main L|✔] | |
10:04 $ sed -n '/alias/,$p' .git/config | |
[alias] | |
show-tag-date = tag --list --format "%(taggerdate:unix)" | |
flux-latest-stage-tag = describe --abbrev=0 --tags --match 'stage/*' main | |
flux-latest-prod-tag = describe --abbrev=0 --tags --match 'prod/*' main | |
flux-state = show --oneline --no-patch main stage prod | |
# git flux-rollback [stage|prod] | |
flux-rollback = "!git branch -f $1 $( git describe --abbrev=0 --tags --match="$1/*" ${1}^ ) && git tag -m \"rollback $1\" ${1}/$(date +'%F-%H-%M-%S')/rollback $1 #" | |
flux-stage = !git tag -m 'promote to stage' stage/$(date +'%F-%H-%M-%S') refs/heads/main && git branch -f stage $( git flux-latest-stage-tag ) | |
flux-promote = "!if [[ $(git show-tag-date $(git flux-latest-stage-tag)) -le $(git show-tag-date $(git flux-latest-prod-tag --exclude '*/rollback')) ]]; \ | |
then echo \"stage's $(git flux-latest-stage-tag) isn't newer than prod's $(git flux-latest-prod-tag --exclude '*/rollback')\"; \ | |
else git tag -f -m 'promote to prod' prod/$(date +'%F-%H-%M-%S') $( git describe --abbrev=0 --tags --match 'stage/*' main )'^{commit}' && git branch -f prod $( git describe --abbrev=0 --tags --match 'prod/*' main ); fi" | |
#else git tag -f -m 'promote to prod' prod/$(date +'%F-%H-%M-%S') $( git rev-list -1 $( git describe --abbrev=0 --tags --match 'stage/*' main ) ) && git branch -f prod $( git describe --abbrev=0 --tags --match 'prod/*' main ); fi" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Demo recording:
