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

[WIP] Allow skipping commits that don't contain changes relative to the project path. #223

Closed
wants to merge 1 commit into from
Closed

[WIP] Allow skipping commits that don't contain changes relative to the project path. #223

wants to merge 1 commit into from

Conversation

danielcweber
Copy link

@danielcweber danielcweber commented Sep 13, 2018

Consider the following scenario:

  • I have a solution (.sln) with multiple projects (.csproj) in subfolders.
  • These projects each produce a nuget package.
  • A version.json is present in the solution-folder.
  • On a build server (DevOps), always the complete solution is built, resulting in a new nupkg for each project, even if there were only changes in one of the projects.

I want to have a new package version only for the projects that have had changes. Having a separate version.json in each subfolder obviously won't work since the git height will still increase each time. This PR is a proof of concept and work in progress to enable skipping commits that don't contain any changes for the directory of the project, thus excluding them from contributing to the git height. This is enabled by setting <SkipCommitsWithoutChangesInPath>true</SkipCommitsWithoutChangesInPath> in MsBuild.

The PR is in early stages, there are changes in signatures of public methods and I'm sure I missed a lot of code paths so that the new feature won't work in all cases. Depending on whether this change is considered useful, I will continue work on this.

…ject path. If a commit is skipped, is does not contribute to the height.
@AArnott
Copy link
Collaborator

AArnott commented Sep 14, 2018

Thanks for contributing. Two quick thoughts, acknowledging I haven't yet seen your change:

  1. Settings always go in the version.json file, since this will impact more than msbuild.
  2. We probably want to consider cases where a change to a referenced project (transitively) also causes the version bump.

@danielcweber
Copy link
Author

danielcweber commented Sep 14, 2018

We probably want to consider cases where a change to a referenced project (transitively) also causes the version bump.

That's indeed not considered in my scenario. That adds some layers of complexity...

I'm considering whether my approach is so useful after all if cross-references are considered. Maybe it's advisable to split up solutions in that case.

@AArnott
Copy link
Collaborator

AArnott commented Sep 14, 2018

Maybe it's advisable to split up solutions in that case.

I appreciate your flexibility in thinking about how it could be implemented. That would indeed simplify it. However based on conversations I've had in #160, I think the primary use case includes projects within the same solution having unique version heights. Finding transitive P2Ps references for all projects is impossible, but for .NET SDK projects might be possible, but as it would depend on MSBuild insights it may be undesirable anyway. So counting P2Ps may just be a requirement we can't meet. I'll ask for a vote on #160 to see how folks react.

@japj
Copy link
Contributor

japj commented Feb 2, 2019

So to summarize, we need a way to calculate which paths contribute to the git height.

  1. for a fully isolated project (e.g. no project references), the project folder would be 'enough'

  2. for a project with (ProjectReference) dependencies, the paths to the project references also contribute to the git height (and this might be recursive)

  3. for projects that make use of "known MSBuild import hooks" (e.g. Directory.Build.props/targets) the folders with the import hooks contribute to the git height

  4. and 3) will indeed depend on MSBuild insights.
    Perhaps a "first" version of this mechanism could just contain a manual option to specify which (toplevel) folder contributes to git height. That way it would be an opt-in (for those "that know what they are doing").

A next version of this logic could then be prototyped/worked on to see how "correct" it can be made with actual MSBuild logic?

@AArnott
Copy link
Collaborator

AArnott commented Feb 2, 2019

Ya, thinking about it more, I suspect a transitive walk along P2P refs is probably a non-starter for several reasons. Having the user explicitly specify the set of folders (allowing more than one) that contribute to the height is probably sufficient.

@japj japj mentioned this pull request Mar 4, 2019
6 tasks
AArnott pushed a commit that referenced this pull request Nov 15, 2023
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.

None yet

3 participants