@@ -18,6 +18,10 @@ const autoDev = async (): Promise<void> => {
1818 const optimistic = getInput ( 'optimistic' ) === 'true'
1919 const comments = getInput ( 'comments' ) === 'false'
2020 const base = getInput ( 'base' ) || 'master'
21+ const comment = async ( successfulPulls : Pull [ ] ) : Promise < void > =>
22+ comments
23+ ? createComments ( token , owner , repo , pulls , successfulPulls )
24+ : Promise . resolve ( )
2125
2226 const allPulls = await fetchPulls ( token , owner , repo )
2327 const pulls = allPulls
@@ -27,21 +31,23 @@ const autoDev = async (): Promise<void> => {
2731 branch : pull . head . ref
2832 } ) )
2933
30- if ( pulls . length === 0 ) {
31- info ( '🎉 No Pull Requests found. Nothing to merge.' )
32- return
33- }
34-
34+ await exec ( 'git fetch' )
3535 await exec ( `git config --global user.email "${ email } "` )
3636 await exec ( `git config --global user.name "${ user } "` )
37- await exec ( 'git fetch' )
3837 await exec ( 'git checkout dev' )
3938 await exec ( `git reset --hard origin/${ base } ` )
4039
41- const comment = async ( successfulPulls : Pull [ ] ) : Promise < void > =>
42- comments
43- ? createComments ( token , owner , repo , pulls , successfulPulls )
44- : Promise . resolve ( )
40+ if ( pulls . length === 0 ) {
41+ if ( await hasDiff ( 'HEAD' , `origin/${ branch } ` ) ) {
42+ await exec ( 'git push -f' )
43+ info (
44+ `🎉 No Pull Requests found. Pushed changes, because "${ branch } " and "${ base } " diverged.`
45+ )
46+ } else {
47+ info ( '🎉 No Pull Requests found. Nothing to merge.' )
48+ }
49+ return
50+ }
4551
4652 const message = optimistic
4753 ? await merge ( base , pulls , comment )
0 commit comments