Visitar URL original
`update-pr-from-base-branch` sometimes doesn't add the button · Issue #3155 · refined-github/refined-github · GitHub
Skip to content

update-pr-from-base-branch sometimes doesn't add the button #3155

Closed

Description

@FloEdelmann

E.g. in this PR the button is not added although the branch is out-of date. The feature bails out directly because I can't merge the PR (it's a fork of a repo I don't have access to):

https://github.com/sindresorhus/refined-github/blob/7589633720493550e359468ffdb4294858b74646/source/features/update-pr-from-base-branch.tsx#L97-L105

I can successfully call the update-branch API endpoint though. I tested that in a similar PR by commenting out the lines above and clicking the button.

Because the logic when to add / don't add the button seems quite complicated and has changed quite a bit in the past (9022674, 4b3fff7, 45e4323, 5787ed7, c5ab9a9, 15600fe), I haven't really tried to solve it myself.

These are the rules I worked out myself (please add more I forgot!):

  • If you can't edit the PR (because you opened it or have repo access), bail out ❌
  • If the branch is not out-of-date, bail out. ❌
  • If the head is unknown repository, bail out ❌
  • If the repo enabled the Require branches to be up to date before merging branch setting, there is already an "Update branch" button. ❌
  • If the branch has merge conflicts and the PR is not a draft, there is already a "Resolve conflicts" button. ❌
  • In all other cases, add the button. ✔️

Activity

  1. changed the title [-]`update-pr-from-base-branch` sometimes doesn't show the button[/-] [+]`update-pr-from-base-branch` sometimes doesn't add the button[/+] on May 29, 2020
  2. fregante commented on May 29, 2020

    @fregante
    Member

    Yes, regarding the 4th point, a generic “if it already exists, don’t add” behavior should work. However I’ve regularly seen 2 buttons on some PRs due to this feature.

  3. fregante commented on May 30, 2020

    @fregante
    Member

    As mentioned in #3154, I'm not seeing the button on this draft PR either (#3153)

    Here's the DOM:

    <div class="mergeability-details js-details-container Details">
    	<div class="branch-action-item">
    		<!-- '"` --><!-- </textarea></xmp> -->
    		<form class="branch-action-btn float-right" action="/sindresorhus/refined-github/pull/3153/ready_for_review" accept-charset="UTF-8" method="post">
    			<input type="hidden" name="pull_request_id" value="MDExOlB1bGxSZXF1ZXN0NDI0NjIwODMy" />
    			<button class="btn" type="submit" data-disable-with="">Ready for review</button>
    		</form>
    		<div class="branch-action-item-icon completeness-indicator completeness-indicator-problem">
    			{ICON}
    		</div>
    		<div class="h4 status-heading">This pull request is still a work in progress</div>
    		<span class="status-meta">Draft pull requests cannot be merged.</span>
    	</div>
    
    	<div class="branch-action-item js-details-container Details">
    		<div class="branch-action-item-icon completeness-indicator completeness-indicator-success">
    			{ICON}
    		</div>
    
    		<div class="">
    			<button type="button" class="btn-link float-right js-details-target" aria-expanded="true">
    				<span class="statuses-toggle-opened">Hide all checks</span>
    				<span class="statuses-toggle-closed">Show all checks</span>
    			</button>
    
    			<h3 class="h4 status-heading">All checks have passed</h3>
    			<span class="status-meta">4 successful checks</span>
    		</div>
    
    		<div class="merge-status-list js-updatable-content-preserve-scroll-position" data-updatable-content-scroll-position-id="merge-status-list">
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Security (pull_request)
    					</strong>
    
    					Successful in 6s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3153/checks?check_run_id=717653634" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / AVA (pull_request)
    					</strong>
    
    					Successful in 43s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3153/checks?check_run_id=717653603" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Lint (pull_request)
    					</strong>
    
    					Successful in 37s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3153/checks?check_run_id=717653652" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Build (pull_request)
    					</strong>
    
    					Successful in 38s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3153/checks?check_run_id=717653584" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    		</div>
    	</div>
    
    	<div class="merge-message">
    		<div class="select-menu d-inline-block">
    			<div class="BtnGroup position-relative">
    				<button type="button" class="btn-group-merge border-right-0 rounded-left-1 btn BtnGroup-item js-details-target" aria-expanded="false" data-details-container=".js-merge-pr" disabled="">
    					Merge pull request
    				</button>
    
    				<button type="button" class="btn-group-squash border-right-0 rounded-left-1 btn BtnGroup-item js-details-target" aria-expanded="false" data-details-container=".js-merge-pr" disabled="">
    					Squash and merge
    				</button>
    
    				<button type="button" class="btn-group-rebase border-right-0 rounded-left-1 btn BtnGroup-item js-details-target" aria-expanded="false" data-details-container=".js-merge-pr" disabled="">
    					Rebase and merge
    				</button>
    
    				<button type="button" class="btn select-menu-button BtnGroup-item" aria-label="Select merge method" disabled=""></button>
    			</div>
    		</div>
    
    		<p class="alt-merge-options text-small">
    			<span class="js-remove-unless-platform" data-platforms="windows,mac">
    				You can also
    				<a data-hydro-click='{"event_type":"pull_request.merge_external","payload":{"client_type":"DESKTOP","originating_url":"https://github.com/sindresorhus/refined-github/pull/3153","user_id":1402241}}' data-hydro-click-hmac="3df843dc2f8e6e67690fa56a6d07b77616a4fded79f7c13753a8b73e90f17677" href="x-github-client://openRepo/https://github.com/sindresorhus/refined-github?branch=pr%2F3153&amp;pr=3153">open this in GitHub Desktop</a>
    			</span>
    			or view
    			<button name="button" type="button" class="btn-link js-details-target" aria-expanded="false" data-hydro-click='{"event_type":"pull_request.merge_external","payload":{"client_type":"GIT","originating_url":"https://github.com/sindresorhus/refined-github/pull/3153","user_id":1402241}}' data-hydro-click-hmac="370175b7a7d154ab079876458bc321f4926cb4e1a79b28d1dc8cbc5cd96e0f2a">
    				command line instructions</button
    			>.
    		</p>
    
    		<git-clone-help-controller class="merge-branch-manually">
    			{CONTENT}
    		</git-clone-help-controller>
    	</div>
    </div>
  4. fregante commented on May 30, 2020

    @fregante
    Member

    It did work on #3148 though. Here's the DOM of that page. A diff might reveal why:

    <div class="mergeability-details js-details-container Details">
    	<div class="branch-action-item">
    		<!-- '"` --><!-- </textarea></xmp> -->
    		<form class="branch-action-btn float-right" action="/sindresorhus/refined-github/pull/3148/ready_for_review" accept-charset="UTF-8" method="post">
    			<input type="hidden" name="pull_request_id" value="MDExOlB1bGxSZXF1ZXN0NDI0MTM0NTUy" />
    			<button class="btn" type="submit" data-disable-with="">Ready for review</button>
    		</form>
    		<div class="branch-action-item-icon completeness-indicator completeness-indicator-problem">
    			{ICON}
    		</div>
    		<div class="h4 status-heading">This pull request is still a work in progress</div>
    		<span class="status-meta">Draft pull requests cannot be merged.</span> <span class="status-meta rgh-update-pr-from-base-branch">You can <button type="button" class="btn-link tooltipped tooltipped-n" aria-label="Merge the master branch into octicons-v2-updates">update the base branch</button>.</span>
    	</div>
    
    	<div class="branch-action-item js-details-container Details">
    		<div class="branch-action-item-icon completeness-indicator completeness-indicator-success">
    			{ICON}
    		</div>
    
    		<div class="">
    			<button type="button" class="btn-link float-right js-details-target" aria-expanded="true">
    				<span class="statuses-toggle-opened">Hide all checks</span>
    				<span class="statuses-toggle-closed">Show all checks</span>
    			</button>
    
    			<h3 class="h4 status-heading">All checks have passed</h3>
    			<span class="status-meta">8 successful checks</span>
    		</div>
    
    		<div class="merge-status-list js-updatable-content-preserve-scroll-position" data-updatable-content-scroll-position-id="merge-status-list">
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Security (pull_request)
    					</strong>
    
    					Successful in 6s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575333" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Security (push)
    					</strong>
    
    					Successful in 7s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575039" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / AVA (pull_request)
    					</strong>
    
    					Successful in 41s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575321" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / AVA (push)
    					</strong>
    
    					Successful in 36s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575076" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Lint (pull_request)
    					</strong>
    
    					Successful in 38s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575305" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Lint (push)
    					</strong>
    
    					Successful in 38s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575092" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Build (pull_request)
    					</strong>
    
    					Successful in 54s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575353" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    			<div class="merge-status-item d-flex flex-items-baseline">
    				<div class="merge-status-icon flex-self-center">
    					{ICON}
    				</div>
    
    				<a href="/apps/github-actions" class="d-inline-block tooltipped tooltipped-e muted-link mr-2 rounded-1" aria-label="@github-actions generated this status." style="background-color: #ffffff;">
    					<img class="avatar" src="https://avatars0.githubusercontent.com/in/15368?s=40&amp;v=4" width="20" height="20" alt="@github-actions" />
    				</a>
    
    				<div class="text-gray col-10 css-truncate css-truncate-target">
    					<strong class="text-emphasized mr-2">
    						Test / Build (push)
    					</strong>
    
    					Successful in 40s
    				</div>
    
    				<div class="d-flex col-2 flex-shrink-0">
    					<a class="status-actions" data-skip-pjax="" href="/sindresorhus/refined-github/pull/3148/checks?check_run_id=716575057" target="_blank" rel="noopener">Details</a>
    				</div>
    			</div>
    		</div>
    	</div>
    
    	<div class="merge-message">
    		<div class="select-menu d-inline-block">
    			<div class="BtnGroup position-relative">
    				<button type="button" class="btn-group-merge border-right-0 rounded-left-1 btn BtnGroup-item js-details-target" aria-expanded="false" data-details-container=".js-merge-pr" disabled="">
    					Merge pull request
    				</button>
    
    				<button type="button" class="btn-group-squash border-right-0 rounded-left-1 btn BtnGroup-item js-details-target" aria-expanded="false" data-details-container=".js-merge-pr" disabled="">
    					Squash and merge
    				</button>
    
    				<button type="button" class="btn-group-rebase border-right-0 rounded-left-1 btn BtnGroup-item js-details-target" aria-expanded="false" data-details-container=".js-merge-pr" disabled="">
    					Rebase and merge
    				</button>
    
    				<button type="button" class="btn select-menu-button BtnGroup-item" aria-label="Select merge method" disabled=""></button>
    			</div>
    		</div>
    
    		<p class="alt-merge-options text-small">
    			<span class="js-remove-unless-platform" data-platforms="windows,mac">
    				You can also
    				<a data-hydro-click='{"event_type":"pull_request.merge_external","payload":{"client_type":"DESKTOP","originating_url":"https://github.com/sindresorhus/refined-github/pull/3148","user_id":1402241}}' data-hydro-click-hmac="fb9985c494088e7b7a2a72e03194d32ec8fedf337ac4e088e86106f3b332bec4" href="x-github-client://openRepo/https://github.com/sindresorhus/refined-github?branch=octicons-v2-updates">open this in GitHub Desktop</a>
    			</span>
    			or view
    			<button name="button" type="button" class="btn-link js-details-target" aria-expanded="false" data-hydro-click='{"event_type":"pull_request.merge_external","payload":{"client_type":"GIT","originating_url":"https://github.com/sindresorhus/refined-github/pull/3148","user_id":1402241}}' data-hydro-click-hmac="c46bfc4203652c7b4188359a769b8c1e1269b4a4dc14b7bb8705648743930858">
    				command line instructions</button
    			>.
    		</p>
    
    		<git-clone-help-controller class="merge-branch-manually">
    			{CONTENT}
    		</git-clone-help-controller>
    	</div>
    </div>

  5. fregante commented on May 30, 2020

    @fregante
    Member

    Here are also some duplicate buttons that appear briefly, after clicking the button itself

  6. FloEdelmann commented on May 30, 2020

    @FloEdelmann
    MemberAuthor

    It makes sure you really know that you can update the base branch 😉

  7. fregante commented on Sep 14, 2020

    @fregante
    Member

    I think this was fixed

  8. natelaws commented on Nov 4, 2020

    @natelaws

    I'm running into two other scenarios where the button isn't showing up:

    • If you don't have the required number of approvers
    • If required status checks are failing

    Screen Shot 2020-11-04 at 2 59 45 PM

    Screen Shot 2020-11-04 at 3 00 07 PM

    It would be really useful if this feature worked in those scenarios.

    A partial workaround is to switch it back to a draft PR, but thats a little awkward.

  9. fregante commented on Nov 4, 2020

    @fregante
    Member

    Can you moved that to a new issue? The selector will have to be updated.

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