Hi again,

I just wanted to post what I've finally came up with by using your
suggestions just in case anyone is curious.

--8<---------------cut here---------------start------------->8---
#!/bin/env fish

argparse 'u/usage' 'l/show-log' -- $argv

if set -q _flag_usage \
    || [ (count $argv) -ne 2 ]
    echo 'Usage: git when-fixed [-l/--show-log] <TICKET> <BRANCH>' >&2
    exit 1
end

set -l sha (git rev-list --grep="$argv[1]\b" --max-count=1 $argv[2])
if test "x$sha" = "x"
    printf 'No commit found for: %s\n' "$argv[1]" >&2
    exit 2
end

echo "Found this commit:"
git log -n1 $sha

set -l tag (git name-rev --tags --name-only --no-undefined "$sha")

if test "x$tag" = "x"
    printf 'No tag found commit: %s\n' $sha >&2
    exit 3
end

echo
echo "Release tag: $tag"

set -l simple_tag (string replace -r "([~^]\d+)+" "" $tag)

if set -q _flag_show_log
    env GIT_PAGER="less --pattern=$sha" git log --graph $simple_tag
end
--8<---------------cut here---------------end--------------->8---

Thanks a lot again,
Tassilo

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/875ze3i1sa.fsf%40gnu.org.

Reply via email to