Skip to content

Commit bb38d4b

Browse files
Merge pull request #19 from Staffbase/fix/sync-dev-with-main
merge updates from main, if there are any
2 parents 9aee599 + 3044c32 commit bb38d4b

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

dist/index.js

Lines changed: 16 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/autodev.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)