Skip to content

"Update Branch" button for stale branches #1236

Closed

Description

@rarkins

Issuehunt badges

Similar to what was discussed by @vanniktech in #1105 but not exactly the same, because I have no interest in a "hot key" - just a button.

Summary:

If you enable branch protection for a repository and select "Require branches to be up-to-date before merging", then you get an Update Branch button whenever the branch goes stale.

image

However it would be convenient to have this for all my PRs, including ones in repositories that don't enforce this branch protection.

As described by @hkdobrev in #1105:

This button would merge the default branch in the PR branch with a merge commit if there are no conflicts.

It might be a little tricky to work out who has write access to that branch when it's coming from a fork. In theory this feature/button could initially work for branches within the same repository only though.

IssueHunt Summary

bfred-it bfred-it has been rewarded.

Sponsors (Total: $80.00)

Tips

Activity

  1. fregante commented on Apr 4, 2018

    @fregante
    Member

    This is interesting, I needed it recently to avoid conflicts (merge + commit = ok; commit + merge = conflict) but I did it via CLI instead.

    This might be possible via API but we don't have API authentication yet in our code. (Edit: we do now!)

    The second issue is that we'd have to make another API every time the thread updates to check if the PR is up to date and add the notice+button (avoidable if we just add the button somewhere).

    I'm thinking this could be more generically implemented in the Compare page, to have an option to merge without a PR:

    On top of this, to facilitate updating the current PR, we could add a link to this page somewhere, if it makes sense. "This page" would be no-reaction-comments...master

  2. fregante commented on Nov 11, 2018

    @fregante
    Member

    Pushing up for discussion

  3. sindresorhus commented on Nov 12, 2018

    @sindresorhus
    Member

    Huge 👍 to @rarkins' proposal. I could have used this many times.

  4. sindresorhus commented on Nov 12, 2018

    @sindresorhus
    Member

    I'm thinking this could be more generically implemented in the Compare page, to have an option to merge without a PR:

    It's not clear to me how this is related to @rarkins' proposal. It seems like a totally different feature.

  5. fregante commented on Nov 12, 2018

    @fregante
    Member

    It's not clear to me how this is related to rarkins' proposal

    "Update branch" means "merge <default branch> into current branch", right? That's what I'm suggesting, except instead of being exclusive to the PR pages, make it work on any branches in any direction.

  6. rarkins commented on Nov 12, 2018

    @rarkins
    Author

    From an "refined github" point of view, I would definitely prefer to just have the button available right in the PR, otherwise it seems like several non-intuitive clicks to get to the compare branches location to do this.

  7. fregante commented on Nov 12, 2018

    @fregante
    Member

    to facilitate updating the current PR, we could add a link to this page somewhere

  8. sindresorhus commented on Nov 12, 2018

    @sindresorhus
    Member

    @bfred-it Ah, got it. I guess that could be useful too, but not something I have ever needed. For non-PR branches, I usually never need to do it in the GitHub UI.

  9. sindresorhus commented on Nov 12, 2018

    @sindresorhus
    Member

    to facilitate updating the current PR, we could add a link to this page somewhere

    That would require two clicks and would not be as clear as a direct button in a PR.

  10. fregante commented on Jan 1, 2019

    @fregante
    Member

    I tried this and it doesn't seem to be feasible (for non-own repos) as the API apparently doesn't care if the user selected "Allow edits from maintainers"

    https://stackoverflow.com/questions/25859077/merge-from-upstream-using-the-github-api

    My test with httpie:

    echo '{"base":"features/jvw-103-190-pr-branches", "head":"e37c15c"}' | http POST 'https://api.github.com/repos/jerone/refined-github/merges' Authorization:"token XXXXXX"
    
    HTTP/1.1 403 Forbidden
    
    {
        "documentation_url": "https://developer.github.com/v3/repos/merging/#perform-a-merge",
        "message": "Must have admin rights to Repository."
    }
    

    I was trying to merge sindresorhus/refined-github@master into #1641


    However it works correctly when pushing to a repo I have push privileges to:

    echo '{"base":"test", "head":"master"}' | http POST 'https://api.github.com/repos/sindresorhus/refined-github/merges' Authorization:"token xxxxxxxxxx"
      
    HTTP/1.1 201 Created
  11. sindresorhus commented on Jan 2, 2019

    @sindresorhus
    Member

    I tried this and it doesn't seem to be feasible (for non-own repos) as the API apparently doesn't care if the user selected "Allow edits from maintainers"

    I see... Too bad. Did you try the GraphQL API? Can you report the issue to GitHub support? Looks like an oversight to me.

    However it works correctly when pushing to a repo I have push privileges to:

    Even if it's just for own PRs on own repos, I think it could still be useful.

  12. 1 remaining item

  13. IssueHuntBot commented on Apr 11, 2019

    @IssueHuntBot

    @IssueHunt has funded $80.00 to this issue.


  14. fregante commented on Apr 16, 2019

    @fregante
    Member

    @rarkins can you post the HTML of that element and its exact position/selector in the dom? We could reuse it as is. Heck if we're lucky we might be able to just submit the same form without dealing with the API.

  15. rarkins commented on Apr 16, 2019

    @rarkins
    Author

    @bfred-it here's the HTML:

      <div class="branch-action-item">
          <!-- '"` --><!-- </textarea></xmp> --></option></form><form class="branch-action-btn float-right js-immediate-updates js-tryable-again js-needs-timeline-marker-header" action="/renovatebot/renovate/pull/3553/update_branch" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="je8sVSxszMFcyxiUCvCfUF9Kv7St0OCQp0T6/BFcajRz//mm7K/wNx8Qrkdd/bo1pqOP5ZI8oxt92cIV5hGFuA==" />
        <input type="hidden" name="expected_head_oid" value="80f2ee48c58fd9595d0390b4a4faf8c6dfea0a38">
        <button type="submit" data-disable-with="Updating branch&hellip;"
            class="btn"
        >
          Update branch
        </button>
    </form>
    
        <div class="branch-action-item-icon completeness-indicator completeness-indicator-problem">
          <svg class="octicon octicon-alert" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"/></svg>
        </div>
        <h3 class="h4 status-heading">This branch is out-of-date with the base branch</h3>
        <span class="status-meta">
          Merge the latest changes from <span class="branch-name">master</span> into this branch.
        </span>
      </div>

    Screenshot of same:
    image

    Selector: #partial-pull-merging > div.merge-pr.js-merge-pr.js-details-container.Details.is-squashing > div > div > div > div:nth-child(3) > form > button

    If you need me to capture anything else, please let me know. I'm not sure how to capture what you ask for re: DOM for example.

  16. self-assigned this
    on Apr 19, 2019
  17. removed their assignment
    on Apr 21, 2019
  18. added
    💵 Funded on Issuehunt
    on May 10, 2019
  19. added and removed
    💵 Funded on Issuehunt
    on May 17, 2019
  20. IssueHuntBot commented on May 17, 2019

    @IssueHuntBot

    @sindresorhus has rewarded $72.00 to @bfred-it. See it on IssueHunt

    • 💰 Total deposit: $80.00
    • 🎉 Repository reward(0%): $0.00
    • 🔧 Service fee(10%): $8.00
  21. fregante commented on May 30, 2019

    @fregante
    Member

    That's awesome! They saw our button on Twitter

  22. locked and limited conversation to collaborators on Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions