Add Merge-Main.ps1 script#30676
Conversation
| &git merge $Source --no-ff --no-commit | ||
|
|
||
| # update paths matching "theirs" except for "ours" and "merge" to the state in $Source | ||
| &git restore -s $Source --staged --worktree -- ":(top,glob)$Theirs" $ourExcludes $mergeExcludes | ||
|
|
||
| # update paths matching "ours" except for "merge" to their pre-merge state | ||
| &git restore -s (git rev-parse HEAD) --staged --worktree -- ":(top,glob)$Ours" $mergeExcludes |
There was a problem hiding this comment.
I think it would be useful to handle exit codes at each of these steps.
There was a problem hiding this comment.
I added an error message function and removed the ampersands
| param( | ||
| [string]$Source = 'main', | ||
| [string[]]$Theirs = @('**'), # paths to always overwrite | ||
| [string[]]$Ours = @('sdk/spring'), # paths to never merge or overwrite |
There was a problem hiding this comment.
spring-experimental should be excluded like spring, the new service directory sdk/jdbc is coming in the main branch, which may be excluded later.
There was a problem hiding this comment.
I added spring-experimental to $Ours.
b45b3b0 to
9919c82
Compare
9919c82 to
adb4a2c
Compare
| # This script can be run locally from the root of the repo: | ||
| # .\eng\scripts\Merge-Branch.ps1 -SourceBranch 'main' -Theirs '**' -Ours 'sdk/template' -Merge 'sdk/template/ci.yml', '**/README.md' | ||
| # | ||
| # This would merge main into the local branch, making the working folder look like main. It not overwrite sdk\template. |
There was a problem hiding this comment.
| # This would merge main into the local branch, making the working folder look like main. It not overwrite sdk\template. | |
| # This would merge main into the local branch, making the working folder look like main. It will not overwrite sdk\template. |
| [string[]]$Merge # paths to merge or overwrite | ||
| ) | ||
|
|
||
| $theirIncludes = @($Theirs | ForEach-Object { ":(top,glob)$_" }) |
There was a problem hiding this comment.
What are these magic include filters? Can you link to the git documentation covering them in a comment?
| " Use `"git commit --no-edit`" to complete the merge with the default merge message`n" ` | ||
| " Use `"git commit -m <message>`" to complete the merge with a custom message" | ||
|
|
||
| exit 0 |
There was a problem hiding this comment.
Isn't there still potential for merge conflicts? If so we should try to detect that and output a message about those conflicts.
There was a problem hiding this comment.
git outputs the appropriate message. It appears in the output just above our "Merge commit started" message
|
@hallipr , please note I have renamed the target branch name to |
|
Hi @hallipr , I will sync code from main to feature/spring-boot-3 now, please help to raise a new PR if any comments should be resolved. |
Use some form of Merge-Branch.ps1 to do the partial sync see Azure/azure-sdk-for-java#30676 see Azure/azure-rest-api-specs-pr#12958
Add script for merging main into the long-lived spring feature branches.
Given a feature/spring branch like:
And a main branch like:
After running Merge-Main.ps1, we would expect an in-progress merge commit like:
The net effect being: