` Git tag ' posortowane w porządku chronologicznym daty commitu wskazanego

Wyjście z git tag jest uporządkowane alfabetycznie. Chciałbym, żeby było uporządkowane chronologicznie (Data commitów, do których są przypisane, a nie data, w której zostały utworzone), w przeciwnym razie wynik powinien pozostać taki sam.

Próbowałem sugestii z http://networkadmin20.blogspot.de/2010/08/howto-list-git-tags-by-date.html , ale kolejność jest nadal taka sama.

Aby upewnić się, że nie jest to błąd w moim repozytorium, próbowałem następujące z czystym repozytorium:

soeren@ubuntu ~/Projects/sandbox % mkdir chronogit
soeren@ubuntu ~/Projects/sandbox % cd chronogit 
soeren@ubuntu ~/Projects/sandbox/chronogit % git init
Initialized empty Git repository in /home/soeren/Projects/sandbox/chronogit/.git/
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % touch a
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git add a
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git commit -m 'a'
[master (root-commit) f88e0e9] a
 0 files changed
 create mode 100644 a
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag 'A-first'
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git mv a b
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git commit -m 'c'
[master ecc0c08] c
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename a => b (100%)
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag 'C-second'
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git mv b c
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git commit -m 'b'
[master e72682d] b
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename b => c (100%)
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag 'B-third'
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git tag
A-first
B-third
C-second
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git for-each-ref refs/tags --sort=taggerdate --format="%(refname:short)"
A-first
B-third
C-second

Pożądany wynik to:

A-first
C-second
B-third

Lub, ponieważ odwrócenie nie powinno być zbyt trudne:

B-third
C-second
A-first

Edit: jak zaznaczono w komentarzach, to pytanie jest dość podobne, więc próbowałem:

soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git log --tags --simplify-by-decoration --pretty="format:%ai %d"          
2013-09-06 16:08:43 +0200  (HEAD, B-third, master)
2013-09-06 16:08:21 +0200  (C-second)
2013-09-06 16:07:42 +0200  (A-first)

Kolejność jest w porządku, ale teraz walczę z formatowaniem ...

soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git log --tags --simplify-by-decoration --pretty="format:%(refname:short)"
%(refname:short)
%(refname:short)
%(refname:short)
soeren@ubuntu ~/Projects/sandbox/chronogit (git)-[master] % git log --tags --simplify-by-decoration --format="%(refname:short)" 
%(refname:short)
%(refname:short)
%(refname:short)
 26
Author: Community, 2013-09-06

5 answers

Właśnie testowałem z git 2.8.0:

git tag --sort=committerdate

Pełna lista nazw pól, których możesz użyć, znajduje się w https://git-scm.com/docs/git-for-each-ref#_field_names

Dla obiektów commit i tag, specjalne pola creatordate i creator będą odpowiadać odpowiedniej krotce Date lub name-email-date z pól commit lub tagger w zależności od typu obiektu. Są one przeznaczone do pracy nad mieszanką adnotacji i lekkich znaczników.

Pola, które mają Nazwa-E-Mail - data krotka jako jej wartość (author, committer, i tagger) może być przyrostkiem name, email, i date, aby wyodrębnić nazwany Składnik.

 22
Author: rraval,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-12-12 15:33:04

W git 2.3.3 mogę po prostu to zrobić, aby uporządkować je według daty:

git tag --sort version:refname

PS: dla przypomnienia, odpowiedziałem również na to samo pytanie duplikat

 20
Author: opsidao,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 11:47:36
git tag | xargs -I@ git log --format=format:"%ai @%n" -1 @ | sort | awk '{print $4}'
 15
Author: soerface,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-09 06:59:02
git log --date-order --tags --simplify-by-decoration --pretty=format:"%ci %d"
 5
Author: seacoder,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-05-01 14:01:37

Spróbuj tego:

git for-each-ref --sort=taggerdate --format '%(refname) %(taggerdate)' refs/tags
Dla mnie działa idealnie i bardzo szybko.

Zobacz Jak mogę wyświetlić listę wszystkich tagów w repozytorium Git według daty ich utworzenia?

 1
Author: John Zhang,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-23 12:03:09