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

Investigate merge driver/merge strategy to reduce merge conflicts on ChangesSinceLastRelease.txt #1246

Closed
elachlan opened this issue Sep 12, 2022 · 18 comments

Comments

@elachlan
Copy link
Contributor

To help PRs get merged faster, we should find a way to reduce merge conflicts on the ChangesSinceLastRelease.txt and enums.json.

@elachlan
Copy link
Contributor Author

@mikebattista I created this issue for fixing the merging issues. I think either a file specific merge driver or a changing in merge strategy will work.

@mikebattista
Copy link
Collaborator

Thanks. @sotteson1 any thoughts on this?

@elachlan
Copy link
Contributor Author

@elachlan
Copy link
Contributor Author

For a singular file you can do the following: https://stackoverflow.com/questions/11841127/strategy-for-git-and-append-mostly-files

@elachlan
Copy link
Contributor Author

Gitlab had a similar problem, this is how they solved it: https://about.gitlab.com/blog/2015/02/10/gitlab-reduced-merge-conflicts-by-90-percent-with-changelog-placeholders/

@mikebattista
Copy link
Collaborator

Interesting. So we just need to add the changes txt file to .gitattributes as shown in the Gitlab blog?

@elachlan
Copy link
Contributor Author

That is my understanding from reading it. I am no expert in git though.

@AArnott
Copy link
Member

AArnott commented Sep 13, 2022

It's worth a shot.

@mikebattista
Copy link
Collaborator

mikebattista commented Sep 13, 2022

I checked in the .gitattributes change. Let's see if it helps.

I started just with the baseline file. If it works, we can try with enums.json as well if that's still complicating merges.

@AArnott
Copy link
Member

AArnott commented Sep 13, 2022

enums.json is a structured file, so a union merge policy may lead to poor results in some cases.

@elachlan
Copy link
Contributor Author

#1245 seems to have a merge conflict. Are they on the ChangesSinceLastRelease.txt? Could be worse with this change.

Also apparently Github recently changed the default merge commit strategy. I thought this would be prudent to mention here.
https://github.blog/changelog/2022-09-12-merge-commits-now-created-using-the-merge-ort-strategy/

@mikebattista
Copy link
Collaborator

Interestingly I just merged a PR with ChangesSinceLastRelease.txt conflicts through VS Code, and VS Code didn't prompt for any merge conflicts. It looks like the changes from both branches were appended to the file. Maybe the browser merge has issues with this approach but local tooling doesn't? Or maybe the merge I did locally was different from the squash and merge we do in the browser?

@AArnott
Copy link
Member

AArnott commented Sep 28, 2022

VS Code uses git.exe to merge, which honors the .gitattributes file for merge rules. Git hosting providers usually don't merge with git.exe for security and scaling reasons, so their support for less-common git configurations like this can be spotty. Are you saying that github wouldn't merge the PR until you merged it locally and pushed first?

@mikebattista
Copy link
Collaborator

I tried merging locally and pushing but got access issues. I then just merged to main on my machine and synced main (again no merge conflicts were reported), however, I just noticed the changes file wasn't merged properly for some reason and it broke the build since some existing changes were apparently removed in the merge.

I'm not sure if .gitattributes is helping or hurting. It's certainly not helping merges in the browser which is what we were trying to optimize.

@mikebattista mikebattista reopened this Sep 28, 2022
@elachlan
Copy link
Contributor Author

Gihub has its own settings against the repo for merge commits and merge strategy. I don't know if they have it for singular files.

We might need to contact someone at GitHub and see what their guidance on it is.

@AArnott
Copy link
Member

AArnott commented Sep 29, 2022

@mikebattista I wonder if the access issue you had in pushing was because you were trying to push directly to main. The standard procedure when a PR has merge conflicts is to checkout the source branch of the PR locally, and then merge origin/main (or whatever the PR target branch is) into the source branch, resolve conflicts, commit, then push (to the PR source branch). That way you still get full PR build validation.

As for not helping merges because github still conflicts, and the local git merge policy that we set produces invalid results, that sounds like an argument for removing this file from source control, and instead producing it in the build and capturing as a pipeline artifact, and having a PR build step be to post a comment to the PR with the diff between the merge-base CI build and the PR build result. This was an option we discussed before, but as it's more work to set up, we wanted to go with the .gitattributes solution first to see how well it worked.

@mikebattista
Copy link
Collaborator

I did what you suggest. The access issue was pushing changes back to the PR branch, not main. The merge issue seems to be that changes from a previous release were included in the changes file from the PR branch, triggering the below error:

*Items from the known differences file that were not used:*
Windows.Win32.System.Wmi.Apis.WBEM_INFINITE added
Windows.Win32.System.Wmi.Apis.WBEM_NO_WAIT added
Windows.Win32.System.Wmi.WBEM_TIMEOUT_TYPE removed
Windows.Win32.System.Wmi.WBEM_TIMEOUT_TYPE.WBEM_INFINITE removed
Windows.Win32.System.Wmi.WBEM_TIMEOUT_TYPE.WBEM_NO_WAIT removed
Windows.Win32.Networking.BackgroundIntelligentTransferService.IBackgroundCopyJobHttpOptions.GetClientCertificate : ppCertHashBlob : [FreeWith(CoTaskMemFree),NativeArrayInfo(CountConst=20),Out] => [FreeWith(CoTaskMemFree),Out]
Windows.Win32.System.Wmi.IWbemServices.ExecQuery : lFlags...Int32 => WBEM_GENERIC_FLAG_TYPE
Windows.Win32.System.Wmi.WBEM_GENERIC_FLAG_TYPE :  => [Flags]
Windows.Win32.System.Wmi.WBEM_GENERIC_FLAG_TYPE.value__...System.Int32 => System.UInt32
Windows.Win32.Graphics.DirectWrite.Apis.DWriteCreateFactory : factory...IUnknown* => Void**
Windows.Win32.UI.WindowsAndMessaging.Apis.TrackPopupMenu : prcRect : [Const,In,Reserved] => [Const,In,Optional]
Windows.Win32.System.Ole.PICTYPE : [Flags] => 
Windows.Win32.Networking.Ldap.Apis.LdapMapErrorToWin32 : LdapError...UInt32 => LDAP_RETCODE
Windows.Win32.Networking.Ldap.Apis.LdapMapErrorToWin32 : return...UInt32 => WIN32_ERROR

It's possible the PR branch had changes from before the latest metadata release, then the local merge unioned the files (per .gitattributes) and included the older changes that were no longer needed. Hence, the "items from the known differences file were not used" error. Will need to test some more with locally merging other PRs that have conflicts.

.gitattributes for sure hasn't helped with browser merging, though.

mikebattista added a commit that referenced this issue Oct 11, 2022
This did not solve the issues with web PRs and is not behaving as expected for local merges with git.exe.
mikebattista added a commit that referenced this issue Oct 11, 2022
* Fixed #1008.

* Updated the baseline.

* Merged main and resolved conflicts.

* Fixed bad merge.

* Removed .gitattributes union merge from #1246.

This did not solve the issues with web PRs and is not behaving as expected for local merges with git.exe.
@mikebattista
Copy link
Collaborator

Closing out for now. Resolving conflicts hasn't been an issue.

@mikebattista mikebattista closed this as not planned Won't fix, can't repro, duplicate, stale Feb 21, 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

No branches or pull requests

3 participants