build process - why does git allow remote tags to move, or why you can't use git-tag for atomic test-and-set -


I have a problem where two similar processes are parallel to different clones of different repositories (usually on different computers) Is running in Each time a process runs, it brings the latest tags from the remote, and then reduces a unique number based on the tag being viewed.

e.g. If these tags are located on remote: 1.0 1.1 1.2 1.3 then one process will be selected as the next number of 1.4.

Before the process begins, it creates a new tag and pushes it back to the remote:

  $ git tag 1.4 head $ git push original tag 1.4  

Thoughts This is a way to select atomic numbers. Other process, if he is looking at the same time, can also decide to use 1.4, but when it comes to pulling the tag, it should be found that 1.4 already exists, and Choose 1.5 instead (and try again).

I was hoping that I can treat the GIT tag as an atom.

Unfortunately, for some strange reason, git allows remote tags to be moved in some specific circumstances!

For example, suppose that tag 1.4 has been put on the original / master and pushed. The second process says to tag 1.4, say, original / master ^, which would include moving the tag backwards. The git will reject it with a 'non-fast forward' error:

Process A:

  $ git tag 1.4 original / master $ git push Original Tag 1.4 total 0 Delta 0), again 0 (Delta 0) reused / repo1 * [new tag] 1.4 - & gt; 1.4  

Process B:

  $ git tag 1.4 original / master ^ $ git push original tag to 1.4 / repo1! [Disapproved] 1.4 - & gt; 1.4 (non-forward forward) error: Failed to push some referee for '/ repo1' OK, that's OK, process B can use it instead to 1.5.  

But consider this situation:

Process A:

  $ git tag 1.4 original / master $ git push original tag 1.4 total 0 ( Delta 0), Reuse 0 (Delta 0) per / repo 1 * [New Tag] 1.4 - & gt; 1.4  

process b:

  $ git tag 1.4 original / master $ git push original tag 1.4 update everything  

Oh it's a shame - GIT did not give an indication that this tag is already present on the remote. In fact, it does with V-V:

  $ git push original tag 1.4-V / in repo1 to / repo1 = [up to date] 1.4 - & gt; 1.4 Everything is up-to-date  

OK, so I can redirect some sort of terrain, search for "=", and this process to determine B Will allow that 1.4 is already in use.

But this is a little silly. And it gets worse:

Process A:

  $ git push Original Tag 1.4 total 0 (delta 0), again in 0 (delta 0) Repo1 * [new tag] 1.4 - & gt; 1.4  

Process B:

 $ git push original tag 1.4 total 0 (delta 0), again in 0 (delta 0) / repo1 fd0e09e. C6cdac9 1.4 - & gt; 1.4  

Arrogance! What? Git has transferred the remote tag without any warning!

So I think that remote tags are routinely broken in GIT - they should not "move" without explicit requests only, apart from the point, they should refuse to go by default.

In addition, the git-tag command should provide a way to molecule and set up on a tag.

But obviously it is not that the GET is not going to help before because there is still a window of struggle and even there is no conflict, then in one of the three situations tag Walks!

What's going on here?

What is another way to test and set up tags?

If not, how do people allocate and reserve build numbers in an automated build environment?

While using GIT 1.6.1.2 how can you be trusted to find out how two processes have unknowingly raised the same build number?

I think the tagging strategy will serve you best if you want to replace the actual tag object Which are designed as more local labels.

You can specify the tag object by specifying one of the -a (or -m / -F ), -s or -us option ( git help tag ).

Try your example, but the tag object of git tag by adding -m "1.4 tag" to each call is the descendant of the other tag object Can not be direct, so every push case that you want to fail may fail.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -