Konstantin Khomoutov <kos...@bswap.ru> writes:

Hi Konstantin,

> The closest thing I can think of is to have a shell script reading
> along these lines:
>
> --------------------------------8<--------------------------------
>   #!/bin/sh
>
>   set -e -u
>
>   if [ $# -ne 1 ]; then
>     printf 'Usage: %s JIRA_TICKET\n' `basename "$0"` >&2
>       exit 1
>   fi
>
>   sha=`git rev-list --grep="$1" --max-count=1 origin/B`
>   if test [ "x$sha" = "x" ]; then
>       printf 'No commit found for: %s\n' "$1" >&2
>       exit 2
>   fi
>
>   git name-rev --tags "$sha"
> --------------------------------8<--------------------------------

Ah, that's a good starting point for me.  Thanks a lot!

> You might want to add more stuff to the `git name-rev` call — like
> passing it the "--no-undefined" command-line option.

I'll read that up.

> If `git name-rev` won't cut it for you, you might resort to a bit more
> programming: the call `git tag --contains <commit-ish>` will return
> you a list of all the tags from which the given commit-ish (any
> encantation which is resolvable to a commit) is reachable.  You can
> now iterate through all those tags, reach for the immediate commits
> they point to, extract commit dates from then and then sort them in
> the reverse chronological order and pick the latest one.

Thanks, I think your original script is pretty much what I want.  Maybe
I would want a way to validate the output of you script.  Is there a way
to fire up a "git log origin/B" and immediately have it "centered" at
the found tag?  I.e., the log should not be filtered but the pager
(less) should immediately scroll to that tag?

Oh, I could answer my question myself!

  env GIT_PAGER="less --pattern=RELEASE_3.7.0.108" \
      git log origin/some-branch

Thanks again!

Bye,
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/87zhck8qv9.fsf%40gnu.org.

Reply via email to