@@ -46,6 +46,8 @@ static async Task AsyncMain(IConfigurationRoot config)
4646 Console . WriteLine ( $ "GitHub organisation: { gitHubConfig [ "organization" ] } ") ;
4747 Console . WriteLine ( $ "GitHub team: { gitHubConfig [ "team" ] } ") ;
4848 Console . WriteLine ( $ "GitHub repository: { gitHubConfig [ "repository" ] } ") ;
49+ Console . WriteLine ( $ "GitHub base branch: { gitHubConfig [ "baseBranch" ] } ") ;
50+ Console . WriteLine ( $ "GitHub new branch: { gitHubConfig [ "branch" ] } ") ;
4951
5052 var members = await query . GetTeamMembers ( gitHubConfig [ "organization" ] , gitHubConfig [ "team" ] ) ;
5153 Console . WriteLine ( $ "Team members ({ members . Count } ):") ;
@@ -83,8 +85,13 @@ static async Task AsyncMain(IConfigurationRoot config)
8385 git . Init ( $ "https://github.com/{ gitHubConfig [ "organization" ] } /{ gitHubConfig [ "repository" ] } .git") ;
8486 git . Fetch ( ) ;
8587 git . ResetHard ( ) ;
86- var baseCommit = git . ParseRef ( "master" ) ;
87- git . CheckoutDetached ( baseCommit ) ;
88+ var baseBranchCommit = git . ParseRef ( gitHubConfig [ "baseBranch" ] ) ;
89+ var mergeBranchCommit = git . ParseRef ( gitHubConfig [ "branch" ] ) ;
90+ git . CheckoutDetached ( baseBranchCommit ) ;
91+ var baseBranchVersion = String . Format ( gitHubConfig [ "versionFormat" ] ?? "{0}" , git . Describe ( gitHubConfig [ "versionDescribeOptions" ] ?? "" ) ) ;
92+ var mergeBranchParents = new List < string > ( ) ;
93+ mergeBranchParents . Add ( baseBranchCommit ) ;
94+ mergeBranchParents . Add ( mergeBranchCommit ) ;
8895 var autoMergePullRequestsSuccess = new List < GraphPullRequest > ( ) ;
8996 var autoMergePullRequestsFailure = new List < GraphPullRequest > ( ) ;
9097 foreach ( var pullRequest in autoMergePullRequests )
@@ -93,6 +100,7 @@ static async Task AsyncMain(IConfigurationRoot config)
93100 try
94101 {
95102 git . Merge ( mergeCommit ) ;
103+ mergeBranchParents . Add ( mergeCommit ) ;
96104 autoMergePullRequestsSuccess . Add ( pullRequest ) ;
97105 }
98106 catch ( ApplicationException )
@@ -101,7 +109,12 @@ static async Task AsyncMain(IConfigurationRoot config)
101109 git . ResetHard ( ) ;
102110 }
103111 }
104- Console . WriteLine ( $ "Final commit: { git . ParseRef ( "HEAD" ) } ") ;
112+ var mergedCommit = git . ParseRef ( "HEAD" ) ;
113+ var newMergeBranchCommit = git . CommitTree ( $ "{ mergedCommit } ^{{tree}}", mergeBranchParents , "Auto-merge" ) ;
114+ git . SetBranchRef ( gitHubConfig [ "branch" ] , newMergeBranchCommit ) ;
115+ Console . WriteLine ( $ "Base branch commit: { baseBranchCommit } ") ;
116+ Console . WriteLine ( $ "Base branch version: { baseBranchVersion } ") ;
117+ Console . WriteLine ( $ "Merge branch commit: { newMergeBranchCommit } ") ;
105118
106119 Console . WriteLine ( $ "Pull requests successfully auto-merged ({ autoMergePullRequestsSuccess . Count } ):") ;
107120 foreach ( var pullRequest in autoMergePullRequestsSuccess )
0 commit comments