docfx icon indicating copy to clipboard operation
docfx copied to clipboard

Lots of GitExceptions on build

Open ygoe opened this issue 8 years ago • 18 comments

DocFX Version Used: 2.39.2

Template used: unchanged

Steps to Reproduce:

  1. Create an ASP.NET Core project that references docfx.console to build the documentation of other projects in the solution
  2. Build the solution, or just the docfx project alone

Expected Behavior:

A successful build, maybe?

Actual Behavior:

This repeats for a very long time, I've cancelled the build.

2>[18-09-18 01:24:04.655]Info:[MetadataCommand.ExtractMetadata]Generating metadata for each project...
2>[18-09-18 01:24:08.729]Warning:[MetadataCommand.ExtractMetadata]Skipping GetFileDetail. Exception found: Microsoft.DocAsCode.Common.Git.GitException, Message:
2>[18-09-18 01:24:08.732]Verbose:[MetadataCommand.ExtractMetadata]Microsoft.DocAsCode.Common.Git.GitException
2>   bei Microsoft.DocAsCode.Common.Git.GitUtility.ProcessErrorMessage(String message)
2>   bei Microsoft.DocAsCode.Common.Git.GitUtility.RunGitCommand(String repoPath, String arguments, Action`1 processOutput)
2>   bei Microsoft.DocAsCode.Common.Git.GitUtility.RunGitCommandAndGetLastLine(String repoPath, String arguments)
2>   bei Microsoft.DocAsCode.Common.Git.GitUtility.GetRepoInfoCore(String directory)
2>   bei System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
2>   bei System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
2>   bei System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
2>   bei System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
2>   bei Microsoft.DocAsCode.Common.Git.GitUtility.GetFileDetailCore(String filePath)
2>   bei Microsoft.DocAsCode.Common.Git.GitUtility.GetFileDetail(String filePath)
2>   bei Microsoft.DocAsCode.Common.Git.GitUtility.TryGetFileDetail(String filePath)

It works on my colleague's computer but not on mine after checking out the code from the Git repo.

ygoe avatar Sep 18 '18 13:09 ygoe

Could you try these commands in your repo and see if git returns some error messages?

git rev-parse --show-toplevel
git config --get remote.origin.url

I can see some error happened when DocFX try call git.exe to get some repository information, but I cannot figure out what happened, as the Message is empty in your attached log. Maybe DocFX should improve the error message here.

superyyrrzz avatar Sep 19 '18 02:09 superyyrrzz

  1. Prints the current directory (repository root)
  2. Prints nothing

ygoe avatar Sep 19 '18 09:09 ygoe

@ygoe , is it possible for you to share with us the folder you are working with? It is hard to tell what is wrong with the error message above.

herohua avatar Sep 28 '18 06:09 herohua

Sorry, this is a closed project. I could try it with a test project when I get to it. Meanwhile, I've disabled the Git features. I'm not sure what they do anyway. On my colleague's computer it was enabled but didn't do anything visible.

ygoe avatar Sep 28 '18 09:09 ygoe

@ygoe

  1. Prints nothing

From this, I guess you get the repository by downloading a zip package and extract, instead of using git clone, so it misses the remote url information. Can you try git clone to fetch the repository?

superyyrrzz avatar Sep 28 '18 09:09 superyyrrzz

No, everything is cloned from the remote. No off-Git downloads.

ygoe avatar Sep 28 '18 10:09 ygoe

Got it. I think a workaround is to run git remote add origin {repo_url} in your repo to set the remote url. Then git config --get remote.origin.url can get the needed information. I believe it can print some info on your colleague's machine. This should solve your issue, but I can not figure out why it is missing on your macihne, as it's set when cloning the repository.

superyyrrzz avatar Sep 29 '18 00:09 superyyrrzz

Ehm, maybe it's because I have chosen another name for the remote? Because "origin" says nothing about where that remote actually is. Does docfx require the hard-coded name "origin" for the remote? That would be just about as inflexible as Git LFS is.

ygoe avatar Sep 30 '18 13:09 ygoe

I have the same problem, and I also don't have a remote called "origin". I just tried DocFX for the first time.

Is there a way to change the name of the remote it's looking for? Git doesn't require a remote called "origin". In fact, the git clone command allows us to give the remote any name we want. So if you do require a remote called "origin", then that might be worth either documenting or fixing.

How do I disable git features?

seth-drf avatar Oct 10 '18 19:10 seth-drf

@ygoe That hard-coded name "origin" is required for now. In some cases, we need to set multiple remote url in local git folder, then DocFX needs to figure out which one to choose. origin should be the right one as it's the default name when clone repo.

Do you have multiple remote url? If not, DocFX can choose the default one, even it's not named original. If yes, then it seems DocFX need a configuration to specify which url to choose, which is more complicated.

@seth-drf try --disableGitFeatures

superyyrrzz avatar Oct 11 '18 06:10 superyyrrzz

There's currently just a single remote, so that could be used. But isn't there also something like a default push remote? Or is that just TortoiseGit's invention?

ygoe avatar Oct 11 '18 16:10 ygoe

@seth-drf You could integrate this into your docfx.json file in the project directory:

{
  "metadata": [
    {
      "disableGitFeatures": true
    }
  ]
}

ygoe avatar Oct 11 '18 16:10 ygoe

The (undocumented) commandline parameter --disableGitFeatures works fine. However, the (also undocumented) metadata value "disableGitFeatures" does not fully disable all Git features and still produces warnings. In addition "disableGitFeatures" is not included in the JSON schema and thus produces a warning in the Visual Studion JSON editor.

Would be great if the metadata value "disableGitFeatures" would work exactly like the commandline parameter, and also be included in the JSON schema at http://json.schemastore.org/docfx. Finally an updated docfx user manual would also be very welcome.

subsembly avatar Oct 31 '18 10:10 subsembly

It looks like "disableGitFeatures" is in the "build" part of docfx.json, not "metadata".

{
  "build": {
    "disableGitFeatures": true
  }
}

iegby avatar Feb 04 '19 18:02 iegby

Putting "disableGitFeatures" into the "build" part did not change anything for me. Still getting all those Exceptions.

subsembly avatar Feb 05 '19 11:02 subsembly

@subsembly @iegby disableGitFeatures is in both build and metadata. --disableGitFeatures set both of them, so it works fine for you.

superyyrrzz avatar Feb 11 '19 07:02 superyyrrzz

I have updated the document to include disableGitFeatures. More ehnacements:

  1. Improve warning message when failing to get information from git.exe
  2. update http://json.schemastore.org/docfx

superyyrrzz avatar May 14 '19 03:05 superyyrrzz

I though this issue can be closed. Because latest docfx implementation don't use git.exe and it's not throw GitException.

filzrev avatar Nov 25 '23 21:11 filzrev