Refined-github: Enable Auto Merging PRs when status checks are required.

Created on 15 May 2018  ·  10Comments  ·  Source: sindresorhus/refined-github

This is a follow up to #865 and #975

If a branch is protected and has the flag Require status checks to pass before merging enabled, then I don't see how I could use the existing feature.

image

Because until those checks aren't successful, I just see a grayed out button and can't press anything:

image

It would be awesome, if there would be another button (created by this extension) next to it, to merge as soon as all checks have passed.

enhancement impossible

Most helpful comment

fwiw this works for me as a browser snippet

function autoMerge() {
    const btn = window.$$('button').filter(el=>el.innerText === 'Merge pull request')[0]
    if (btn) {
        btn.click()
        const btn2 = window.$$('button').filter(btn=>btn.innerText === 'Confirm merge')[0];
        if (btn2) {
            btn2.click()
            return
        }
    }
    setTimeout(autoMerge, 1000)
}
window.$$ = $$;
autoMerge();

All 10 comments

If the form is just hidden but in the dom, then it’s feasible. It can be un-hidden and the checkbox would have to be readonly

I just came across this exact problem too :(
I took a look at the DOM and the ID merge_message_field doesn't exist when Require status checks to pass before merging is checked. This is the ID of the text area with the squash message.
So it looks like it would be slightly harder than just unhiding it :(

This feature would be ✨

I'm adding some gasoline by noting that Azure DevOps currently provides this functionality

To add this feature, we'd have to recreate the whole form, including the logic between merging types. Additionally, we can't know which merging types are available (e.g. a repo only allows Squashing). Sounds impossible 🙁

I think you should ask GitHub to implement our wait-for-build feature (regardless of this requirement)

https://github.com/contact

fwiw this works for me as a browser snippet

function autoMerge() {
    const btn = window.$$('button').filter(el=>el.innerText === 'Merge pull request')[0]
    if (btn) {
        btn.click()
        const btn2 = window.$$('button').filter(btn=>btn.innerText === 'Confirm merge')[0];
        if (btn2) {
            btn2.click()
            return
        }
    }
    setTimeout(autoMerge, 1000)
}
window.$$ = $$;
autoMerge();

That only works if you're fine with the default commit title and message. It's a good workaround but probably most people would expect to be able to preview/edit them.

Thank you for posting it!

@fregante can you add a little message next to the merge button that explains why the feature isn't working? I thought there was an issue with GHR originally

this is now a built-in feature:

https://github.blog/2020-12-08-new-from-universe-2020-dark-mode-github-sponsors-for-companies-and-more/

Auto-merge pull requests (https://github.com/github/roadmap/issues/107): when using protected branches. Rolling out over the next couple of weeks, enabled in your repo settings.

Thanks for the update!

That’s completely different from “Auto-merging” as intended by this extension (i.e. the user still has to click Merge whereas GitHub’s new feature will be completely automatic) but it’s probably what most people are after 🎉

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sindresorhus picture sindresorhus  ·  3Comments

mareksuscak picture mareksuscak  ·  3Comments

hkdobrev picture hkdobrev  ·  3Comments

Arcanemagus picture Arcanemagus  ·  3Comments

pawelad picture pawelad  ·  3Comments