-
Notifications
You must be signed in to change notification settings - Fork 653
[Improvement] Document Git repository requirements #2194
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
Comments
Sounds good. And maybe clear examples for the different CI servers. I'm new to GitVersion, but I see all dev-teams here use different GitVersion.yml files because they're struggling with the options, resulting is messy version numbers and unusable versionnumbers for example for Docker images. Versioning is important and must be done right. But it should be just a small, one-time set-up task you never have to look at anymore. That's not my experience so far. (we use Azure DevOps) |
@kwaazaar, if you use one of the supported Git processes, such as Git flow, the process itself will take care of the versioning and no |
I wonder if... shallow fetching can actually be used with certain branches / workflows. For example, if we use the last tag as the final fallback for a version source, then it might be possible to only fetch back history as far as the last tag? Just a thought. |
Hm, yeah, that's an interesting thought. |
@asbjornu I'm not really familiar with shallow cloning. But conceptually I think what we'd need to do (could be mistaken) is fetch all commit history from current HEAD back to the latest tag - so that if current HEAD isn't tagged, we can still walk the commit history to find the previous commit with the tag and use that as the version source, and then each commit after that tag, adds to the commit count that we use to calculate the final version (plus all other logic that we do). I think fetching history further back than that last tag is probably irrelvent? Is that what I think if we wanted to actually leverage this, we'd need someway of determining what I'm not sure if there is any clever way to calculate that - however a quick search yielded this:
and also this: https://github.com/erasys/git-describe-remote |
Another thought on this requirement
Wondering if we need the entire branch checked out, or if we only need the GitVersion.yml file checkout out (if used). I realise in most cases people will want to be building sources so will most likely want the branch checked out anyway, but I can see in some situations where you are optimising the pipeline you might:
On a large repo with lots of files and lots of history those two steps could have decent impact / saving. From a requirements perspective, I can't think why GitVersion should need any other files checked out? |
It's not about files, but about Git history. In some calcuation strategies, GitVersion needs the history of the current branch at least up to the commit it was branched out from (typically) |
If files aren't needed should "checked out" be a requirement. The only file I can think might be needed is gitversion.yml and that might not be used by everyone so is optional in that sense. If used its possible to do a single file checkout, which might be preferable for jobs that don't build sources, or repo's that contain a lot of files and want to use sparse checkout. It's possible to set the active branch without checking out files like so:
|
Perhaps "checked out" isn't the right terminology. What I mean is that the branch being built should also be the one Git is switched to. |
@asbjornu - yup that makes more sense - have updated that text |
Would requirement 6) be:
I am assuming we don't have logic to auto checkout such a file, or find it somehow without checking it out - but I haven't tested. |
No, we aren't checking out any particular files, the normalization is just to ensure we have history and relevant branches in place. Requirement 6 makes sense, yes. |
Ok cool - added that. Can't think of anything else! |
I lied there was one more thing ;-)
I'm not setting GIT_BRANCH environment variable anywhere and I am using the azure-pipelines task without any problems. Is this a requirement - or is this only required in some circumstances? I remember I used to have to set this for team city builds. |
I think it's required only in some circumstances, but we haven't documented which. It might be that reuirement 4 and 5 are mutually exclusive. |
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions. |
Nice one @asbjornu ! |
🎉 This issue has been resolved in version 5.6.7 🎉 Your GitReleaseManager bot 📦🚀 |
Uh oh!
There was an error while loading. Please reload this page.
Seeing how getting GitVersion to work in different CI servers (Jenkins seems particularly problematic) is a recurring problem, it would be great if we documented GitVersion’s requirements for successfully generating a version number such as:
master
branch.develop
branch (for GitFlow).HEAD
).Git_Branch
as an available environment variable.GitVersion.yml
file, that file should be checked out otherwise it won't be found by GitVersion and default config will apply.Possibly related issues: #1335, #2180, #2118, #2115, #1857, #2233.
The text was updated successfully, but these errors were encountered: