Skip to content

Add update-pr-from-base-branch feature - #1950

Merged
fregante merged 22 commits into
masterfrom
update-branch
May 17, 2019
Merged

fregante merged 22 commits into
masterfrom
update-branch

Conversation

@fregante

@fregante fregante commented Apr 19, 2019 •

Copy link
Copy Markdown
Member

Closes #1236

  • It works only when the branches are on the same repo, because of API limitations
  • It works even if master was force-pushed
  • The name is simplified to master because people get it but it works on any branch
Tasks: all resolved

Tasks

cc @rarkins @sindresorhus

Test

Test it on any PR. It should depend on:

  • User has permission to merge or not
  • PR can be merged or not (e.g. conflicts or reviews required)
  • PR type (draft or normal)

Outdated screenshot https://user-images.githubusercontent.com/1402241/56434750-842de800-6308-11e9-9092-75cd703d4414.png

@fregante

fregante commented Apr 19, 2019 •

Copy link
Copy Markdown
Member Author

The commit above was created with this feature 🎉 371960a

@sindresorhus

sindresorhus commented Apr 26, 2019 •

Copy link
Copy Markdown
Member

Only show if necessary, like when a branch is stale or when GH already shows it

Yes, only show it if the PR branch behind master.

Make less prominent, this shouldn't look like a necessary step.

Agreed. It's only a helpful utility, not a required operation. Not sure where to place it though. Maybe a small link here:
Screen Shot 2019-04-26 at 13 09 45


The name is simplified to master because people get it but it works on any branch

Why not name it update-pr-from-default-branch? Is it really less clear?

Alternatively, document clearly in the file (and in the future, the description field) that it works on any branch.

import * as icons from '../libs/icons';

export async function mergeBranches(repoUrl: string, base: string, head: string) {
const result = await api.v3(`repos/${repoUrl}/merges`, {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The v4 API doesn't support this?

@fregante fregante Apr 26, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think not

@rarkins

rarkins commented Apr 26, 2019

Copy link
Copy Markdown

Re: default vs master terminology. Isn't it technically a third option - i.e. whatever is the "base" branch for the PR?

For example if my default branch is master but I have another branch called something like v3 which is for the next major release, then I may have PRs targeting v3 as the base branch and therefore to sync it with default/master would be incorrect. In such situations we should probably update it from v3 or hide the option if it is not possible.

@fregante

Copy link
Copy Markdown
Member Author

I used master also because we have another feature named after it, but base is actually more correct because that's what this feature looks for.

@fregante
fregante marked this pull request as ready for review May 6, 2019 16:18
@fregante

This comment has been minimized.

@fregante fregante changed the title "Update Branch" button for stale branches Add update-pr-from-base-branch feature May 6, 2019
@fregante

fregante commented May 6, 2019

Copy link
Copy Markdown
Member Author

Even better, link to /conflicts when there are conflicts in Draft PRs

@fregante
fregante requested a review from sindresorhus May 6, 2019 17:05
@fregante fregante mentioned this pull request May 9, 2019
1 of 2 tasks
@sindresorhus

Copy link
Copy Markdown
Member

Seems to work, however:

Only show if necessary, like when a branch is stale or when GH already shows it

This doesn't work correctly. I made a PR (sindresorhus/sindre-playground#4), then updated a file in master, and reloaded the PR, got the "Update branch" button, clicked it, got "Updating branch...", then it disappeared, and then reappeared again, if I click it now, it just switches to "Updating branch...", but nothing happens. If I reload the page 1 minute later, the button no longer shows.

I have a feeling that this is caused by the API taking some time to update its status or something. Still, it's not a very good experience for users.

@fregante

Copy link
Copy Markdown
Member Author

got the "Update branch" button, clicked it, got "Updating branch...", then it disappeared, and then reappeared again, if I click it now, it just switches to "Updating branch...", but nothing happens. If I reload the page 1 minute later, the button no longer shows.

Yeah that’s the second-last to-do on my list, I think I’ll just have to disable the feature after the merge because it’s unlikely to be needed right away

@fregante
fregante force-pushed the update-branch branch 4 times, most recently from dcdd1c5 to 839f4b8 Compare May 15, 2019 16:00
@fregante

fregante commented May 15, 2019 •

Copy link
Copy Markdown
Member Author

I think this is good to go

Screenshot 2019-05-18 at 00 14 18

@sindresorhus

Copy link
Copy Markdown
Member

Looks good now. The only problem is that when you click "Update branch", then it updates, and you refresh the page, the button is there again, as the API is slow to update... I don't think we can do anything about that though.

@fregante
fregante merged commit 4d617ff into master May 17, 2019
@rarkins

rarkins commented May 17, 2019

Copy link
Copy Markdown

Thanks all

@sindresorhus
sindresorhus deleted the update-branch branch May 17, 2019 06:14
@fregante fregante mentioned this pull request May 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

"Update Branch" button for stale branches

4 participants