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
Danger inadvertently making the git repository shallow [teamcity] [bitbucket cloud] #1314
Comments
Perhaps |
Hi, what is the status of this issue? I have a deep git history and running danger is adding around 2min extra just for the shallow copy, for running some scripts that should not need any extra info that the already contained in the current checkout. Any way to force activating/deactivating the shallow? thanks! |
You can switch to Danger JS which only uses the source control APIs to handle it - but Danger in ruby requires both base and head in the git repo to run |
Or use the workaround mentioned in the description. I’m using it since I opened this issue |
My problem is that I want to avoid the |
What about if you limit git fetch to the target branch. You do not need to fetch all, only target branch |
Report
What did you do?
Run Danger on bitbucket cloud + teamcity. Teamcity makes full clones (not shallow) of the PRs
What did you expect to happen?
Running danger does not alter the git repository
What happened instead?
Danger converted the git repository into a shallow clone
Your Environment
Teamcity
Yes, I am running 8.3.1
How does this happen?
I have been troubleshooting the issue for a while. The issue is difficult to reproduce, and it could look like it is aleatory, but it is not. I think this is what is happening:
Scenario 1 [expected]: the git repository stays as full clone (not shallow)
commit-1-in-master
, and adds a commitcommit-1-in-branch
commit-1-in-branch
commit-1-in-master
commit_exists
in here which returns true: the full clone done by teamcity contains both commitscommit-1-in-branch
andcommit-1-in-master
.Scenario 2 [unexpected]: the repository gets converted to shallow
After a while,
master
branch gets new commits:commit-2-in-master
,commit-3-in-master
,commit-4-in-master
... And now danger behaves differently. See below scenario:commit-2-in-branch
commit-2-in-branch
commit-4-in-master
commit_exists
in here which returns false for thecommit-4-in-master
: such commit is not part of the clone done by teamcity! The clone only containscommit-1-in-branch
,commit-2-in-branch
andcommit-1-in-master
git_fetch_branch_to_depth
here, which converts the repository to shallow (is this known, is it expected?)How to troubleshoot it?
Not so easy. I end up modifying the danger gem in place and added some prints:
Under scenario 2, I get the following output in my CI (I replaced real commit hashes with their equivalent based on above explanation):
Why is this a problem?
commit-1-in-master
:git branch "branch" --contains "commit-0-in-master"
returns the current branch, as expectedgit branch "branch" --contains "commit-0-in-master"
does not return the current branchWhat could be a solution?
Workaround
Run
git fetch origin master
before running danger, so all commits needed by danger are already in the clone, avoiding the call to thegit_fetch_branch_to_depth
functionThe text was updated successfully, but these errors were encountered: