Skip to content

When using gitHub flow we don't need to Fetch other branches then master #85

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 1 commit into from
Mar 7, 2014

Conversation

nulltoken
Copy link
Contributor

Can we have an environment configuration switch or argument to stop this error... (?)

[UpdateAssemblyInfo] GitFlowVersionTask.UpdateAssemblyInfo [18:06:08][GitFlowVersionTask.UpdateAssemblyInfo] Applicable build agent found: 'TeamCity'. [18:06:08][GitFlowVersionTask.UpdateAssemblyInfo] Executing PerformPreProcessingSteps for 'TeamCity'. [18:06:08][GitFlowVersionTask.UpdateAssemblyInfo] One remote found (origin -> 'https://[email protected]/Particular/Website.Backend.git'). [18:06:08][GitFlowVersionTask.UpdateAssemblyInfo] Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*. [18:06:08] [GitFlowVersionTask.UpdateAssemblyInfo] Error occurred: LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Net (Error). Request failed with status code: 401 at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) at LibGit2Sharp.Core.Proxy.git_remote_connect(RemoteSafeHandle remote, GitDirection direction) at LibGit2Sharp.Network.DoFetch(RemoteSafeHandle remoteHandle, FetchOptions options) at LibGit2Sharp.Network.Fetch(Remote remote, FetchOptions options) at GitFlowVersion.GitFlowVersion.GitHelper.NormalizeGitDirectory(String gitDirectory) in c:\BuildAgent\work\5e0d79a4e3943b17\GitFlowVersion\BuildServers\GitHelper.cs:line 17 at GitFlowVersion.TeamCity.PerformPreProcessingSteps(String gitDirectory) in c:\BuildAgent\work\5e0d79a4e3943b17\GitFlowVersion\BuildServers\TeamCity.cs:line 20 at GitFlowVersionTask.UpdateAssemblyInfo.InnerExecute() in c:\BuildAgent\work\5e0d79a4e3943b17\GitFlowVersionTask\UpdateAssemblyInfo.cs:line 85 at GitFlowVersionTask.UpdateAssemblyInfo.Execute() in c:\BuildAgent\work\5e0d79a4e3943b17\GitFlowVersionTask\UpdateAssemblyInfo.cs:line 43

@andreasohlund
Copy link
Contributor

So in this case @sfarmar want to use GitHubFlow and in that case we don't need to fetch branches?

I guess since we use the existence of "develop" branch as the thing enabling GHF we need to make the calls?

Perhaps we can add a Mode=GHF switch/env/etc that allows users to avoid this?

@JakeGinnivan
Copy link
Contributor

That is not true, you still need to fetch if you want pull request support to work

Also tags are not fetched by default I don't think, so at a minimum we need to fetch tags

@andreasohlund
Copy link
Contributor

Ah, got it. So the fix is to hope ssl support gets into lib2gitsharp?

On Fri, Feb 21, 2014 at 8:33 AM, Jake Ginnivan [email protected]:

That is not true, you still need to fetch if you want pull request support
to work

Also tags are not fetched by default I don't think, so at a minimum we
need to fetch tags

Reply to this email directly or view it on GitHubhttps://github.com//issues/85#issuecomment-35705227
.

@nulltoken
Copy link
Contributor

Ssl is supported AFAIK.

@andreasohlund
Copy link
Contributor

@sfarmar can you add the exact config you used in TC that caused this?

On Fri, Feb 21, 2014 at 10:28 AM, nulltoken [email protected]:

Ssl is supported AFAIK.

Reply to this email directly or view it on GitHubhttps://github.com//issues/85#issuecomment-35711449
.

@seanfarmar
Copy link
Author

I'v worked around this by adding this build step (ps) Thanks @andreasohlund

$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\cmd"
$env:path += ";" + (Get-Item "Env:ProgramFiles(x86)").Value + "\Git\bin"


curl -e "Authorization: token cf79a18e5c6923e476559fc7d32de73a5dfc8af3" https://api.github.com/user

git config remote.origin.url https://sfarmar:[email protected]/Particular/Website.Backend.git

$branchBeingBuilt = . git symbolic-ref --short -q HEAD  
. git pull 2>&1 | write-host
foreach ($remoteBranch in . git branch -r) {   
  . git checkout $remoteBranch.Trim().Replace("origin/", "") 2>&1 | write-host     
  . git pull 2>&1 | write-host  
}  
. git checkout $branchBeingBuilt 2>&1 | write-host  
exit 0

@SimonCropp
Copy link
Contributor

@andreasohlund why did you close this?

  • at best the workaround is a hack that is hard for users to discover.
  • if it is githubflow we should not be pulling in branches. so why not implement this?
  • @nulltoken says ssl is supported so if we are using gitflow it should still work.

Seem like we have some viable improvements here.

@andreasohlund
Copy link
Contributor

Pretty sure this was a dupe but I was wrong. Reopened

@andreasohlund andreasohlund reopened this Feb 24, 2014
@andreasohlund
Copy link
Contributor

After talking to @nulltoken we have a proposed solution for this:

Since lib2gitsharp supports a username /pwd we can modify:

https://github.com/Particular/GitVersion/blob/master/GitFlowVersion/BuildServers/GitHelper.cs#L17

To check for the existence of 2 environment variables:

GITVERSION_REMOTE_USERNAME
GITVERSION_REMOTE_PASSWORD

if those are present we call the other overload to fetch that will then authenticate and be able to fetch the branches.

Here is the doco for that overload:

https://github.com/libgit2/libgit2sharp/blob/vNext/LibGit2Sharp.Tests/FetchFixture.cs#L52-L74

@nulltoken
Copy link
Contributor

@andreasohlund Added what we discussed about. See the attached commit.

andreasohlund added a commit that referenced this pull request Mar 7, 2014
When using gitHub flow we don't need to Fetch other branches then master
@andreasohlund andreasohlund merged commit caff915 into master Mar 7, 2014
@andreasohlund andreasohlund deleted the ntk/fetch_auth branch March 7, 2014 14:33
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.

5 participants