Skip to content

Fix tracking branches in dynamic repositories #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 20, 2015
Merged

Fix tracking branches in dynamic repositories #464

merged 2 commits into from
Jun 20, 2015

Conversation

johannesegger
Copy link

When running GitVersion with a dynamic repository using a new branch it cannot find a remote tracking branch. I dug a bit deeper and found that in GitHelper.CreateMissingLocalBranchesFromRemoteTrackingOnes the remoteTrackingReference is a DirectReference, but I think it should be a SymbolicReference for this to work.

I'm not sure how to fix this as I'm not familiar with LibGit2Sharp. Any advice?

@gep13
Copy link
Member

gep13 commented Jun 15, 2015

Is this still happening on the V3 beta branch, or is this only on v2?

@johannesegger
Copy link
Author

I tried this on master (97dade8), which is ahead of 3.0.0-Beta3

@gep13
Copy link
Member

gep13 commented Jun 15, 2015

Just to confirm, the 3.0.0 release hasn't been merged yet:

https://github.com/ParticularLabs/GitVersion/tree/release/3.0.0

Can you try on this?

@johannesegger
Copy link
Author

Sorry, I don't understand, running git merge-base master release/3.0.0 outputs 24fa6b5 which is essentially release/3.0.0, so what do you mean by it hasn't been merged yet?

@gep13
Copy link
Member

gep13 commented Jun 15, 2015

To the best of my knowledge, although I hadn't checked, the beta code hasn't been merged to master, but I could be wrong. @JakeGinnivan could confirm.

You could well be right, and I am just a little behind 😸

@johannesegger
Copy link
Author

Yeah, GitHub also says that release/3.0.0 is 0 commits ahead of master and 4 commits behind it :-)

@JakeGinnivan
Copy link
Contributor

Sorry for confusion, I am just using release branch for releasing betas. Am keeping master in sync/ahead

Sent from my Windows Phone


From: Johannes Eggermailto:[email protected]
Sent: ‎15/‎06/‎2015 09:54
To: ParticularLabs/GitVersionmailto:[email protected]
Subject: Re: [GitVersion] Fix tracking branches in dynamic repositories (#464)

I tried this on master (97dade897dade8), which is ahead of 3.0.0-Beta3


Reply to this email directly or view it on GitHubhttps://github.com//pull/464#issuecomment-111983608.

@JakeGinnivan
Copy link
Contributor

Ping @nulltoken, thoughts on the libgit2sharp question?

@nulltoken
Copy link
Contributor

I dug a bit deeper and found that in GitHelper.CreateMissingLocalBranchesFromRemoteTrackingOnes the remoteTrackingReference is a DirectReference, but I think it should be a SymbolicReference for this to work.

@JakeGinnivan Thanks for the ping!

@eggapauli Could you please elaborate further regarding what makes you think that?

@johannesegger
Copy link
Author

I was wrong. I think the problem was that a local ref was added, but it wasn't set up to track the remote ref.
I tried to do this in the second commit. Again, I'm not familiar with libgit2sharp and found your answer on how to update a branch to track a remote one.

@@ -203,6 +205,9 @@ static void CreateMissingLocalBranchesFromRemoteTrackingOnes(Repository repo, st
{
repo.Refs.Add(localCanonicalName, new ObjectId(symbolicReference.ResolveToDirectReference().TargetIdentifier), true);
}

var branch = repo.Branches[branchName];
repo.Branches.Update(branch, b => b.TrackedBranch = remoteTrackingReferenceName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would GV be run on a development environment, this would blindly overwrite the potentially existing tracking configuration for every considered branch. Is this expected?

/cc @JakeGinnivan

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these statements are only executed for newly created branches, otherwise they are skipped due to the if statement in line 192.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, this normalisation code should only ever happen on the build server.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without that if statement which was highlighted. Are there any other scenarios this could happen?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(other than normalisation)

JakeGinnivan added a commit that referenced this pull request Jun 20, 2015
…repo

Fix tracking branches in dynamic repositories
@JakeGinnivan JakeGinnivan merged commit 76b0bc2 into GitTools:master Jun 20, 2015
@johannesegger johannesegger deleted the no-tracking-branch-in-dynamic-repo branch June 20, 2015 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants