Skip to content
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

Shallow clone lacks of commits even I did not clone anything #837

Closed
TeaTime762 opened this issue Oct 6, 2022 · 6 comments
Closed

Shallow clone lacks of commits even I did not clone anything #837

TeaTime762 opened this issue Oct 6, 2022 · 6 comments
Labels

Comments

@TeaTime762
Copy link

TeaTime762 commented Oct 6, 2022

When calling nbgv cloud I get this exception.

Nerdbank.GitVersioning.GitException: Shallow clone lacks the objects required to calculate version height. Use full clones or clones with a history at least as deep as the last version height resetting change.

NuGet version: 3.4.255
tool version: 3.4.205

I used this older versions as we have a repository where it works with the same settings.
It also do not work with latest versions.

@AArnott
Copy link
Collaborator

AArnott commented Oct 6, 2022

Are you running this on a shallow clone?

@TeaTime762
Copy link
Author

No, I did not clone anything.

@AArnott
Copy link
Collaborator

AArnott commented Oct 6, 2022

Nerdbank.GitVersioning requires to be run inside a git repo. If you didn't clone anything (and didn't create the repo locally to begin with) then you'd get a different error. So it's very likely you cloned, or are running in an environment where the clone was made for you. And if that's the case, you should check how the clone was made, because it was likely made as a shallow clone. And, per the error message, that's what you need to go fix.

@TeaTime762
Copy link
Author

I am sorry I gave too little details. Thanks for your patience.

I run nbgv in a repo on azure devops but I did not clone the repo from elsewhere, I started from scratch.
Azure DevOps does a checkout during the build pipeline to a pseudo branch.
Here I got the error.

These are the git informations:

Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Syncing repository: printer-react-ui (Git)
Prepending Path environment variable with directory containing 'git.exe'.
git version
git version 2.36.1.windows.1
git lfs version
git-lfs/2.13.3 (GitHub; windows amd64; go 1.16.2; git a5e65851)
git init "D:\a\1\s"
Initialized empty Git repository in D:/a/1/s/.git/
git remote add origin https://kurtzgmbh.visualstudio.com/3dPrinter/_git/printer-react-ui
git config gc.auto 0
git config --get-all http.https://kurtzgmbh.visualstudio.com/3dPrinter/_git/printer-react-ui.extraheader
git config --get-all http.extraheader
git config --get-regexp .*extraheader
git config --get-all http.proxy
git config http.version HTTP/1.1
git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 +5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780:refs/remotes/origin/5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780
remote: Azure Repos        
remote: 
remote: Found 80 objects to send. (35 ms)        
From https://kurtzgmbh.visualstudio.com/3dPrinter/_git/printer-react-ui
 * [new ref]         5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780 -> origin/5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780
git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1 +5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780
remote: Azure Repos        
remote: 
remote: Found 0 objects to send. (2 ms)        
From https://kurtzgmbh.visualstudio.com/3dPrinter/_git/printer-react-ui
 * branch            5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780 -> FETCH_HEAD
git checkout --progress --force refs/remotes/origin/5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780
Note: switching to 'refs/remotes/origin/5149c4d9dcf26a7be6f1a6e485ea5c62cf1e7780'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 5149c4d Merged PR 1048: Update azure-pipelines.yml for Azure Pipelines
Finishing: Checkout printer-react-ui@main to s

@AArnott
Copy link
Collaborator

AArnott commented Oct 6, 2022

Thanks. I see --depth=1 in that log, so you are indeed getting a shallow clone. You can read more about this at Azure Pipelines.

See https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/cloudbuild.md#azure-pipelines for how to fix this.

@AArnott AArnott closed this as not planned Won't fix, can't repro, duplicate, stale Oct 6, 2022
@TeaTime762
Copy link
Author

TeaTime762 commented Oct 6, 2022

Thank you so much.
My lack of understanding of git leads to not reading your documentation carefully enough, sorry for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants