Skip to content

Commit

Permalink
Merge pull request whyrusleeping#201 from whyrusleeping/feat/contrib
Browse files Browse the repository at this point in the history
contrib: add gx-retrotag script
  • Loading branch information
Stebalien authored Aug 30, 2018
2 parents c590921 + 69d2999 commit 855ebcf
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contrib/README.md
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]
```
33 changes: 33 additions & 0 deletions contrib/gx-retrotag.sh
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

0 comments on commit 855ebcf

Please sign in to comment.