dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.07k stars 865 forks source link

Lots of GitExceptions on build #3433

Closed ygoe closed 11 months ago

ygoe commented 6 years ago

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.

superyyrrzz commented 6 years ago

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.

ygoe commented 6 years ago
  1. Prints the current directory (repository root)
  2. Prints nothing
herohua commented 6 years ago

@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.

ygoe commented 6 years ago

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.

superyyrrzz commented 6 years ago

@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?

ygoe commented 6 years ago

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

superyyrrzz commented 6 years ago

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.

ygoe commented 6 years ago

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.

seth-drf commented 6 years ago

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?

superyyrrzz commented 6 years ago

@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

ygoe commented 6 years ago

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 commented 6 years ago

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

{
  "metadata": [
    {
      "disableGitFeatures": true
    }
  ]
}
subsembly commented 6 years ago

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.

iegby commented 5 years ago

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

{
  "build": {
    "disableGitFeatures": true
  }
}
subsembly commented 5 years ago

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

superyyrrzz commented 5 years ago

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

superyyrrzz commented 5 years ago

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
filzrev commented 11 months ago

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