-
Notifications
You must be signed in to change notification settings - Fork 865
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
Branch name for git detached head #1098
Conversation
Hi @richardschneider, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution! TTYL, DNFBOT; |
Hi @richardschneider , thanks for your contribution. From my point, I don't think DocFX should handle the case. Consider a scenario, what if users just need generate the My suggestion is that you need resolve the issue in CI tools instead of in DocFX. Such as running command What do you think about it? |
AppVeyor is popular in open source dev because it uses a Windows VM and is free. My workflow is simple: Build code, Test Code, Publish to Nuget, Generate Doc, publish to gh-pages. docfx does not work in this environment. It has the wrong branch name in the generated .yml files. How is this not a docfx bug? The logic was placed in the Utility class because this is where the bug is. It uses |
Did you read
#1098 (comment)
I'm of the opinion that this is docfx bug.
…On 2 January 2017 at 19:22, Qinen Zhu ***@***.***> wrote:
???
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1098 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAmhFeLvaCGn03E--DB2Wr3DaXIGoM4Wks5rOJe1gaJpZM4LYqjd>
.
|
What if users just need generate the |
@qinezh I don't understand your concern about I am simply fixing the branch name for an edge case (a git detached head). Existing code will work as before. This fix has nothing to do with a |
The concern is that the code here highly dependents on CI's implementation. |
@vicancy good idea. I'll add it add the head of list, so it overrides all other environment variables. I want to keep the other env names so that that docfx works with other build systems without having to make to make any changes. |
@richardschneider How about a section talking about setting up CI in |
@vicancy excellent. I was just looking at folder structure to find out where to this info. Could you tell me the folder/file to update. |
Really appreciate your contributions @richardschneider 😄 , |
# Conflicts: # src/Microsoft.DocAsCode.Common/Git/GitUtility.cs
|
||
Setting the environment variable `DOCFX_SOURCE_BRANCH_NAME` tells DocFX which branch name to use. | ||
|
||
Many build systems set an environment variable with the branch name. DocFX uses the following: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support DOCFX_SOURCE_BRANCH_NAME
is enough? Use documentation to tell CI users how to configure environment variables with different build systems?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to have docfx run on common the build system without any special instructions.
[Trait("Owner", "makaretu")] | ||
public class GitUtilityTest | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove extra empty lines
{ | ||
remoteBranch = remoteBranch.Substring(index + 1); | ||
} | ||
remoteBranch = localBranch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogInfo to tell users that branch name is found in env
|
||
// Many build systems use a "detach head", which means that the normal git commands | ||
// to get branch names do not work. Thankfully, they set an environment variable. | ||
string localBranch = BuildSystemBranchName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the BuildSystemBranchName is found in env, however the repo is not in a detached mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable names are overrides. If any is specified, then the first specifies the branch name.
Hi @richardschneider, the concern with your PR is that it introduces a new overwriting mechanism through Environment Variables for a specific case. Actually To support your case, we plan to support overwriting the git url for source files, aka, |
@vicancy I was just trying to get doxfx to work, as expected, with appyevor. If you want developers to jump through hoops and spend hours googling to get it to work then go for it and document it. Also, it's my opinion that most documentation is generated on a build server, not on an individual I thought I had a simple fix for this, but obviously I am wrong. |
Hi @richardschneider I agree with you that the simplicity of setting up
So that Again, really appreciate your patience and continuous contribution to |
Hi @vicancy and thanks for all comments.
PR already does this.
Okay, will make a change.
PR already does this. |
…tached head The code is ugly but this logic has been been requested by the team.
remoteBranch = RunGitCommandAndGetFirstLine(repoRootPath, GetRemoteBranchCommand); | ||
var index = remoteBranch.IndexOf('/'); | ||
if (index > 0) | ||
var isDetached = "HEAD" == RunGitCommandAndGetFirstLine(repoRootPath, GetLocalBranchCommand); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"HEAD" == Run [](start = 32, length = 14)
merge with GetLocalBranchName?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the addition of GetLocalBranchName
is wrong. It changes the semantics of both RepoInfo.LocalBranch
and RepoInfo.RemoteBranch
. Previously they held a git branch name. Now they can also hold a commit id
.
I want nothing to do with this. Its evil.
Not sure what you mean by "HEAD" == Run [](start = 32, length = 14)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However the code here is exactly GetLocalBranchName
. And they have duplicate logic checking detached
. Please make the code change cleaner rather than more complex.
remoteBranch = localBranch; | ||
Logger.LogInfo($"Using branch '{localBranch}' from the environment variable."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also log the environment variable name
Many build systems use a "detached head", which means that the normal git commands to get branch names do not work. Thankfully, they set an environment variable. The various environment variable names was obtained from https://github.com/GitTools/GitVersion
Bug #1097
Here's an example of it now working on AppVeyor https://ci.appveyor.com/project/richardschneider/docfx-seed/build/1.0.8