# [PATCH] Ability to automaticaly push tags to remote repositories.

3 messages from 2006-03-30 to 2006-06-02. Participants: Krzysiek Pawlik, Petr Baudis.
Thread: https://gitlist.dev/t/3757

## Krzysiek Pawlik, 2006-03-30 12:56

Subject: [PATCH] Ability to automaticaly push tags to remote repositories.
Message-ID: <442BD562.3030207@people.pl>
URL: https://gitlist.dev/e/442BD562.3030207%40people.pl

```
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


- From `cg-push --long-help`:

- -t TAG::
        Tells cg-push to also push the given tag. Note that in the
        future, cg-push should push tags automatically. Also note
        that even if you pass `cg-push` the '-t' arguments, your
        HEAD is still pushed as well in addition to the tags.

One of possible ways of doing it is in attached patch. Comments,
suggestions?

- --
Krzysiek Pawlik (Nelchael)
RLU #322999 GPG Key ID: 0xBC555551
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEK9Vigo/w9rxVVVERAvXkAJ42ESjs3REY0ECqIYlbz+9WX/3+ZQCfSQs/
B4X6U2io0Wq0/0oiolpUW1g=
=3ZR7
-----END PGP SIGNATURE-----


Ability to automaticaly push tags to remote repositories.

---
commit 6e581cf43ccf7236ea47ac4ba9b51df9cda3c671
tree b440cb8e4629c5c77e38fb6179992b52edf8c861
parent 891c6d85f38a326e91d62906e1696a38d28fb105
author Krzysiek Pawlik <kpawlik@silvermedia.pl> Thu, 30 Mar 2006 14:48:36 +0200
committer Krzysiek Pawlik <kpawlik@silvermedia.pl> Thu, 30 Mar 2006 14:48:36 +0200

 cg-push |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/cg-push b/cg-push
index 4332b28..865cbd5 100755
--- a/cg-push
+++ b/cg-push
@@ -43,17 +43,32 @@ send_pack_update()
 
 locbranch="$_git_head"
 tags=()
+auto_push_tags=yes
 while optparse; do
 	if optparse -r=; then
 		locbranch="$OPTARG"
 		[ "$(cg-object-id -c "$locbranch")" ] || exit 1
 	elif optparse -t=; then
 		tags[${#tags[@]}]="refs/tags/$OPTARG"
+		auto_push_tags=no
 	else
 		optfail
 	fi
 done
 
+if [ "${auto_push_tags}" = "yes" ]; then
+	if [ ! -d "$_git/cogito-tags-pushed" ]; then
+		mkdir "$_git/cogito-tags-pushed" || die "can't create cache for pushed tags"
+	fi
+	for i in `cg-tag-ls | awk '{print $1}'`; do
+		if [ ! -f "$_git/cogito-tags-pushed/${i}" ]; then
+			echo "Adding ${i} to list of tags to push"
+			tags[${#tags[@]}]="refs/tags/${i}"
+			touch "$_git/cogito-tags-pushed/${i}"
+		fi
+	done
+fi
+
 [ ${#ARGS[@]} -gt 1 ] && die "too many arguments, I can push only one branch at once"
 name="${ARGS[0]}"
 



!-------------------------------------------------------------flip-



```

## Krzysiek Pawlik, 2006-03-30 14:18

Subject: Re: [PATCH] Ability to automaticaly push tags to remote repositories.
Message-ID: <442BE8C2.5000907@people.pl>
URL: https://gitlist.dev/e/442BE8C2.5000907%40people.pl
In-Reply-To: <442BD562.3030207@people.pl>

```
Krzysiek Pawlik wrote:
> Comments, suggestions?

Broken when there are no tags. Attached patch fixes it.

-- 
Krzysiek Pawlik (Nelchael)
RLU #322999 GPG Key ID: 0xBC555551



Fix auto-push of tags when there are no tags.

---
commit eff67bafe333c28c238feb614f098b987216ffb0
tree 8758ae4a2eace9c4fdf64ec89c1f983871097a74
parent 6e581cf43ccf7236ea47ac4ba9b51df9cda3c671
author Krzysiek Pawlik <kpawlik@silvermedia.pl> Thu, 30 Mar 2006 16:10:26 +0200
committer Krzysiek Pawlik <kpawlik@silvermedia.pl> Thu, 30 Mar 2006 16:10:26 +0200

 cg-push |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/cg-push b/cg-push
index 865cbd5..40016c1 100755
--- a/cg-push
+++ b/cg-push
@@ -60,7 +60,7 @@ if [ "${auto_push_tags}" = "yes" ]; then
 	if [ ! -d "$_git/cogito-tags-pushed" ]; then
 		mkdir "$_git/cogito-tags-pushed" || die "can't create cache for pushed tags"
 	fi
-	for i in `cg-tag-ls | awk '{print $1}'`; do
+	for i in `cg-tag-ls 2> /dev/null | awk '{print $1}'`; do
 		if [ ! -f "$_git/cogito-tags-pushed/${i}" ]; then
 			echo "Adding ${i} to list of tags to push"
 			tags[${#tags[@]}]="refs/tags/${i}"



!-------------------------------------------------------------flip-



```

## Petr Baudis, 2006-06-02 20:58

Subject: Re: [PATCH] Ability to automaticaly push tags to remote repositories.
Message-ID: <20060602205836.GG10488@pasky.or.cz>
URL: https://gitlist.dev/e/20060602205836.GG10488%40pasky.or.cz
In-Reply-To: <442BD562.3030207@people.pl>

```
Dear diary, on Thu, Mar 30, 2006 at 02:56:02PM CEST, I got a letter
where Krzysiek Pawlik <krzysiek.pawlik@people.pl> said that...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> - From `cg-push --long-help`:
> 
> - -t TAG::
>         Tells cg-push to also push the given tag. Note that in the
>         future, cg-push should push tags automatically. Also note
>         that even if you pass `cg-push` the '-t' arguments, your
>         HEAD is still pushed as well in addition to the tags.
> 
> One of possible ways of doing it is in attached patch. Comments,
> suggestions?

Well, this works properly only when you ever push to a single
repository, which many people don't. Besides, if you have two branches,
push branch A but tag a commit only on branch B, you will now be pushing
an invalid tag since the other end won't have the branch B and thus the
tagged commit.

A better way would be to use git-ls-remote --tags to get the list of
remote tags and compare that with the list of local tags, then push
those tags that tag commits on the branch we are pushing and the other
end does not have them.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.

```
