Skip to content

change prerelease tag to local.timestamp when building locally #2069

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

Closed
wants to merge 6 commits into from
Closed

change prerelease tag to local.timestamp when building locally #2069

wants to merge 6 commits into from

Conversation

jetersen
Copy link
Contributor

@jetersen jetersen commented Jan 30, 2020

fixes #1570

@@ -77,6 +78,12 @@ public SemanticVersion FindVersion(GitVersionContext context)
}
}

if (context.IsLocalBuild && taggedSemanticVersion == null && context.Repository.RetrieveStatus().IsDirty)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why this is superior to our current solution we have with our own msbuild target.
We can check if the repo is dirty in GitVersion 😍

cc @zionyx

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I wonder if that's what we want.
We properly want to have all local build marked with local.timestamp when I think about our use case for local nuget repository source.

@jetersen

This comment has been minimized.

@jetersen jetersen marked this pull request as ready for review January 31, 2020 06:33
@@ -33,7 +33,8 @@ public void RunExecViaCommandLine()
var result = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, ExecCommand.BuildTool, "RunExecViaCommandLine.csproj /target:OutputResults");

result.ExitCode.ShouldBe(0, result.Log);
result.Log.ShouldContain("GitVersion_FullSemVer: 1.2.4+1");
var now = DateTime.Now.ToString("yyyyMMddHH");
result.Log.ShouldMatch($".+GitVersion_FullSemVer: 1.2.4-local.{now}\\d+\\+1.+");
Copy link
Contributor Author

@jetersen jetersen Jan 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great we already had a test that constituted as a dirty repo 😍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should properly add a dirty one and none dirty? to see when build is local 👍

Copy link
Member

@asbjornu asbjornu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the rationale behind this change. Why would you want a new version number every hour when building locally? One of GitVersion's strengths imho is being able to generate the same version number for the same commit on the same branch no matter where it is being built. This seems to break that premise.

@@ -75,13 +76,13 @@ private string ResolveCurrentBranch(IBuildServer buildServer, string targetBranc
return currentBranch;
}

private VersionVariables GetCachedGitVersionInfo(string targetBranch, string commitId, Config overrideConfig, bool noCache)
private VersionVariables GetCachedGitVersionInfo(string targetBranch, string commitId, Config overrideConfig, bool noCache, bool isCiBuild)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we stick to either isLocalBuild or isCiBuild to avoid confusion?

Suggested change
private VersionVariables GetCachedGitVersionInfo(string targetBranch, string commitId, Config overrideConfig, bool noCache, bool isCiBuild)
private VersionVariables GetCachedGitVersionInfo(string targetBranch, string commitId, Config overrideConfig, bool noCache, bool isLocalBuild)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was indecisive on wording I think isLocalBuild is best. I must have missed this one.

@jetersen
Copy link
Contributor Author

@asbjornu the hour thing is only for tests that ignores minutes and seconds cause it would be cause test failures.

The local version number is timestamped down to seconds so everytime you build you will get a new package version with the new version.

Together with custom PackageOutputPath and GeneratePackageOnBuild this will generate a new package with a new timestamp that you can use in your local package source.

The desire for this is ease local development between libraries.

@jetersen
Copy link
Contributor Author

I will agree that this may not be something for GitVersion to accept as it is very different premise.

Perhaps it could be hidden behind a GitVersion configuration otherwise we will continue to use our current solution we have in our specialized msbuild targets.

@arturcic
Copy link
Member

@asbjornu the hour thing is only for tests that ignores minutes and seconds cause it would be cause test failures.

The local version number is timestamped down to seconds so everytime you build you will get a new package version with the new version.

Together with custom PackageOutputPath and GeneratePackageOnBuild this will generate a new package with a new timestamp that you can use in your local package source.

The desire for this is ease local development between libraries.

To be honest I don't think we need to cover this specific scenario

@arturcic
Copy link
Member

arturcic commented Feb 12, 2020

@asbjornu the hour thing is only for tests that ignores minutes and seconds cause it would be cause test failures.
The local version number is timestamped down to seconds so everytime you build you will get a new package version with the new version.
Together with custom PackageOutputPath and GeneratePackageOnBuild this will generate a new package with a new timestamp that you can use in your local package source.
The desire for this is ease local development between libraries.

To be honest I don't think we need to cover this specific scenario

This specific scenario should be handled outside of the GitVersion tool

@jetersen
Copy link
Contributor Author

No worries, thanks for taking the time to review the PR ❤️

@jetersen jetersen closed this Feb 12, 2020
@asbjornu
Copy link
Member

I think #1385 points to a direction you might take to solve this, @Casz. See assembly-file-versioning-format for details. It may not support your exact use-case now, but a continuation of it in the right direction might and will be more likely to be something we'll accept and merge.

@jetersen
Copy link
Contributor Author

Thanks may look into assembly-file-versioning-format and whether it is helpful 😅

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

Successfully merging this pull request may close these issues.

Increment version number when local changes are detected
3 participants