forked from whyrusleeping/gx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request whyrusleeping#201 from whyrusleeping/feat/contrib
contrib: add gx-retrotag script
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Scripts that make using GX nicer | ||
|
||
## gx-retrotag | ||
|
||
`gx-retrotag` retroactively adds git tags to commits that modify .gx/lastpubver | ||
(gx release commits). | ||
|
||
1. Fetches $remote (defaults to origin). | ||
2. Tags the relevant commits (on $branch only, defaults to master). | ||
3. Pushes the tags back to $remote. | ||
|
||
Usage: | ||
|
||
```sh | ||
> ./gx-retrotag.sh [[remote] branch] | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
remote=${1:-origin} | ||
branch=${2:-master} | ||
|
||
echo "fetching $remote" | ||
git fetch "$remote" | ||
|
||
for h in $(git log "$remote/$branch" --format=format:'%H' .gx/lastpubver); do | ||
# get the gx version at this point | ||
ver="$(git show $h:.gx/lastpubver 2>/dev/null | cut -d: -f1)" || continue | ||
|
||
# Skip empty versions | ||
[[ -n "$ver" ]] || continue | ||
|
||
|
||
# skip if the tag exists | ||
if git show-ref "v$ver" "$ver" >/dev/null; then | ||
continue | ||
fi | ||
|
||
# tag it. | ||
echo "tagging $ver ($h)" | ||
git tag -s -m "release $ver" "v$ver" $h | ||
changed=true | ||
done | ||
|
||
if [[ -n "$changed" ]]; then | ||
echo "pushing tags to $remote" | ||
git push --tags --repo="$remote" | ||
else | ||
echo "nothing to do" | ||
fi |