git describe [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>…]
git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit.
—tags
Instead of using only the annotated tags, use any tag found in refs/tags namespace. This option enables matching a lightweight (non-annotated) tag.
—contains
Instead of finding the tag that predates the commit, find the tag that comes after the commit, and thus contains it. Automatically implies –tags.
Git - git-describe Documentation
開発ブランチを触りつつメンテブランチも触りつつで色々直していると “あの” 修正は、
- どのブランチに反映されているか
- どのバージョン (tag) で反映されているか
といったことを確認することがしばしば。主に障害のフィードバック。
いちおうそういったことを管理しているはずの web システムが有るのだけど、あまり役に立たないので自分で調べることがしばしば。単純に branch 指定で git log
するのもだるくなってきたので効率よくやりたい。
やりたいこと
- 捜索対象のブランラチの一覧を作る →
git branch -r
したものから絞る - 対象のブランチに対して任意の文字列で
grep
する →git log branch_name —grep hoge
grep
でヒットしたコミットがどのブランチのどのバージョン (tag) に含まれるかを出力する →git describe
3 つ目のどのバージョン (tag) に含まれるかを調べるのがかなりめんどくさいだろうなぁと思いつつググったり help を見てたりしてたら describe
があった。
$ g describe --tag --contains ecedc25 v1.2
対象のタグとの差分も出力されるので表にしてみる。
commit | tag | describe |
---|---|---|
d0c7c9e | HEAD | fatal: cannot describe |
ecedc25 | v1.2 | v1.2 |
d034dd8 | v1.2~1 | |
4474ba2 | v1.2~2 | |
ad28b95 | v1.2~3 | |
cc21f52 | v1.2~4 | |
838ac48 | v1.2~5 | |
d6e515e | v1.1 | v1.1 |
17ea342 | v1.1~1 | |
fbc098d | v1.0 | v1.0 |
—abbrev=0
を指定すれば ~
といった差分は出なくなりそうな気がするのだけど・・・よく分からないので放置。やりたいことはできたので、以前作っていた go 製ツールに組み込んでリリース予定。
今回、vim-go を試しに入れてみたら補完ができるようになったので激しくやる気がでてきた。型を定義してインスタンス生成するのがおっくうな程度にまだ慣れてないので色々書いてサラサラいきたい。