From 1e3359c4b33961d01bf0293f64d4f7ab455d069e Mon Sep 17 00:00:00 2001 From: Joe Block Date: Tue, 19 Nov 2024 09:55:47 -0700 Subject: [PATCH 1/2] Add Daniel's `git-semvers` Add `git-semvers` that lists all tags in a repo that are semver-compliant. Signed-off-by: Joe Block --- README.md | 1 + bin/git-list-semvers | 1 + bin/git-semvers | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 120000 bin/git-list-semvers create mode 100755 bin/git-semvers diff --git a/README.md b/README.md index 06eca04f9..d9d6daf15 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ If you wrote one of these scripts and want it removed from this collection, plea | `git-rm-deleted-from-repo` | Joe Block | Removes files you deleted with `rm` from the repository for you. | | `git-root-directory` | Joe Block | Prints the path to the root of the `git` repository you're in. | | `git-run-command-on-revisions` | Gary Bernhardt's [dotfiles](https://github.com/garybernhardt/dotfiles) | Runs a given command over a range of `git` revisions. | +| `git-semvers` | [Daniel Hoherd](http://github.com/danielhoherd) | List all the tags in a repo that are semver compliant | | `git-shamend` | Danielle Sucher's [git-shamend](http://www.daniellesucher.com/2014/05/08/git-shamend/) blog post | Amends your staged changes as a fixup (keeping the pre-existing commit message) to the specified commit, or HEAD if no revision is specified. | | `git-show-overwritten` | Mislav Marohnić's [dotfiles](https://github.com/mislav/dotfiles) | Aggregates `git blame` information about the original owners of lines changed or removed in the '...' diff. | | `git-shrink-repo` | Based on [gimbo/gimbo-git.zsh](https://github.com/gimbo/gimbo-git.zsh/blob/master/gimbo-git.zsh) | Shrinks your clone of a `git` repository. | diff --git a/bin/git-list-semvers b/bin/git-list-semvers new file mode 120000 index 000000000..1bdd4581f --- /dev/null +++ b/bin/git-list-semvers @@ -0,0 +1 @@ +git-semvers \ No newline at end of file diff --git a/bin/git-semvers b/bin/git-semvers new file mode 100755 index 000000000..61a80a774 --- /dev/null +++ b/bin/git-semvers @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# Originally from hangops slack + +set -o pipefail +set -e + +if [[ -n "$DEBUG" ]]; then + # shellcheck disable=SC2086 + if [[ "$(echo $DEBUG | tr '[:upper:]' '[:lower:]')" == "verbose" ]]; then + set -x + fi +fi + +function debug() { + if [[ -n "$DEBUG" ]]; then + echo "$@" + fi +} + +function echo-stderr() { + echo "$@" 1>&2 ## Send message to stderr. +} + +function fail() { + printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way. + exit "${2-1}" ## Return a code specified by $2 or 1 by default. +} + +function my-name() { + basename "$0" +} + +function usage() { + echo "Usage: $(my-name) ARG ARG" +} + +git tag -l "v*.*.*" --sort=-v:refname | awk -F. '!seen[$1,$2]++' \ No newline at end of file From a1cf3a9e4b12c99e5e7d876b6ebfd27c47171bf6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 16:57:17 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- bin/git-semvers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-semvers b/bin/git-semvers index 61a80a774..5b695feb9 100755 --- a/bin/git-semvers +++ b/bin/git-semvers @@ -35,4 +35,4 @@ function usage() { echo "Usage: $(my-name) ARG ARG" } -git tag -l "v*.*.*" --sort=-v:refname | awk -F. '!seen[$1,$2]++' \ No newline at end of file +git tag -l "v*.*.*" --sort=-v:refname | awk -F. '!seen[$1,$2]++'