@@ -47,7 +47,7 @@ static async Task AsyncMain(IConfigurationRoot config)
4747 Console . WriteLine ( $ "GitHub team: { gitHubConfig [ "team" ] } ") ;
4848 Console . WriteLine ( $ "GitHub repository: { gitHubConfig [ "repository" ] } ") ;
4949 Console . WriteLine ( $ "GitHub base branch: { gitHubConfig [ "baseBranch" ] } ") ;
50- Console . WriteLine ( $ "GitHub new branch: { gitHubConfig [ "branch " ] } ") ;
50+ Console . WriteLine ( $ "GitHub merge branch: { gitHubConfig [ "mergeBranch " ] } ") ;
5151
5252 var members = await query . GetTeamMembers ( gitHubConfig [ "organization" ] , gitHubConfig [ "team" ] ) ;
5353 Console . WriteLine ( $ "Team members ({ members . Count } ):") ;
@@ -86,12 +86,13 @@ static async Task AsyncMain(IConfigurationRoot config)
8686 git . Fetch ( ) ;
8787 git . ResetHard ( ) ;
8888 var baseBranchCommit = git . ParseRef ( gitHubConfig [ "baseBranch" ] ) ;
89- var mergeBranchCommit = git . ParseRef ( gitHubConfig [ "branch" ] ) ;
89+ var mergeBranchCommit = git . ParseRef ( gitHubConfig [ "mergeBranch" ] ) ;
90+ var mergeBranchTree = git . ParseRef ( $ "{ mergeBranchCommit } ^{{tree}}") ;
9091 git . CheckoutDetached ( baseBranchCommit ) ;
9192 var baseBranchVersion = String . Format ( gitHubConfig [ "versionFormat" ] ?? "{0}" , git . Describe ( gitHubConfig [ "versionDescribeOptions" ] ?? "" ) ) ;
9293 var mergeBranchParents = new List < string > ( ) ;
93- mergeBranchParents . Add ( baseBranchCommit ) ;
9494 mergeBranchParents . Add ( mergeBranchCommit ) ;
95+ mergeBranchParents . Add ( baseBranchCommit ) ;
9596 var autoMergePullRequestsSuccess = new List < GraphPullRequest > ( ) ;
9697 var autoMergePullRequestsFailure = new List < GraphPullRequest > ( ) ;
9798 foreach ( var pullRequest in autoMergePullRequests )
@@ -109,17 +110,8 @@ static async Task AsyncMain(IConfigurationRoot config)
109110 git . ResetHard ( ) ;
110111 }
111112 }
112- var mergedCommit = git . ParseRef ( "HEAD" ) ;
113- var mergedMessage = String . Format ( gitHubConfig [ "mergeMessageFormat" ] ,
114- baseBranchVersion ,
115- autoMergePullRequestsSuccess . Count ,
116- String . Join ( "" , autoMergePullRequestsSuccess . Select ( pr => String . Format ( gitHubConfig [ "mergeMessagePRFormat" ] , pr . Number , pr . Title ) ) )
117- ) ;
118- var newMergeBranchCommit = git . CommitTree ( $ "{ mergedCommit } ^{{tree}}", mergeBranchParents , mergedMessage ) ;
119- git . SetBranchRef ( gitHubConfig [ "branch" ] , newMergeBranchCommit ) ;
120- Console . WriteLine ( $ "Base branch commit: { baseBranchCommit } ") ;
121- Console . WriteLine ( $ "Base branch version: { baseBranchVersion } ") ;
122- Console . WriteLine ( $ "Merge branch commit: { newMergeBranchCommit } ") ;
113+ var autoMergeCommit = git . ParseRef ( "HEAD" ) ;
114+ var autoMergeTree = git . ParseRef ( $ "{ autoMergeCommit } ^{{tree}}") ;
123115
124116 Console . WriteLine ( $ "Pull requests successfully auto-merged ({ autoMergePullRequestsSuccess . Count } ):") ;
125117 foreach ( var pullRequest in autoMergePullRequestsSuccess )
@@ -132,6 +124,30 @@ static async Task AsyncMain(IConfigurationRoot config)
132124 {
133125 Console . WriteLine ( $ " #{ pullRequest . Number } { pullRequest . Title } ") ;
134126 }
127+
128+ if ( mergeBranchTree == autoMergeTree )
129+ {
130+ Console . WriteLine ( "No changes to push into merge branch" ) ;
131+ }
132+ else
133+ {
134+ var newMergeBranchMessage = String . Format ( gitHubConfig [ "mergeMessageFormat" ] ,
135+ baseBranchVersion ,
136+ autoMergePullRequestsSuccess . Count ,
137+ String . Join ( "" , autoMergePullRequestsSuccess . Select ( pr => String . Format ( gitHubConfig [ "mergeMessagePRFormat" ] , pr . Number , pr . Title ) ) )
138+ ) ;
139+ var newMergeBranchCommit = git . CommitTree ( $ "{ autoMergeCommit } ^{{tree}}", mergeBranchParents , newMergeBranchMessage ) ;
140+ git . SetBranchRef ( gitHubConfig [ "mergeBranch" ] , newMergeBranchCommit ) ;
141+ git . Checkout ( gitHubConfig [ "mergeBranch" ] ) ;
142+ var newMergeBranchVersion = String . Format (
143+ gitHubConfig [ "mergeVersionFormat" ] ?? gitHubConfig [ "versionFormat" ] ?? "{0}" ,
144+ git . Describe ( gitHubConfig [ "mergeVersionDescribeOptions" ] ?? gitHubConfig [ "versionDescribeOptions" ] ?? "" ) ,
145+ git . GetCommitDate ( newMergeBranchCommit )
146+ ) ;
147+ Console . WriteLine ( "Pushed changes into merge branch:" ) ;
148+ Console . WriteLine ( $ " Version: { newMergeBranchVersion } ") ;
149+ Console . WriteLine ( $ " Message: { newMergeBranchMessage . Split ( "\n " ) [ 0 ] } ") ;
150+ }
135151 }
136152
137153 static string GetGitPath ( )
0 commit comments