Skip to content

Meta: Use new APIs in update-pr-from-base-branch - #6103

Merged
yakov116 merged 20 commits into
mainfrom
v4
Nov 1, 2022
Merged

yakov116 merged 20 commits into
mainfrom
v4

Conversation

@yakov116

@yakov116 yakov116 commented Oct 23, 2022 •

Copy link
Copy Markdown
Member

Test URLs

refined-github/sandbox#9 (Conflict)
refined-github/sandbox#11

Screenshot

NA

Comment thread source/github-helpers/get-pr-info.ts Resolved
@yakov116 yakov116 added the meta Related to Refined GitHub itself label Oct 23, 2022
@yakov116 yakov116 changed the title Use new APIs in update-pr-from-base-branch Meta: Use new APIs in update-pr-from-base-branch Oct 23, 2022
@yakov116

Copy link
Copy Markdown
Member Author

@busches will this affect GHE?

@yakov116
yakov116 marked this pull request as ready for review October 23, 2022 20:38
@busches

busches commented Oct 23, 2022

Copy link
Copy Markdown
Member

@yakov116 you can check the GHE docs to see what, if any, versions support it yet. Guessing it's not in any version yet.

@fregante

Copy link
Copy Markdown
Member

@yakov116 we have probably never waited for GHE to use updated APIs

@yakov116

yakov116 commented Oct 23, 2022 •

Copy link
Copy Markdown
Member Author

This will break the entire feature, since the api call will fail.

I don't remember in the past ever having a case where an API was not available on GHE.

However I do remember holding off on v4 until GHE had normal support.

I am not waiting to support the API I am just using a fallback.

@busches

busches commented Oct 23, 2022

Copy link
Copy Markdown
Member

I do use this feature all the time, so I appreciate the thought. 😃

Comment thread source/features/restore-file.tsx Resolved
Comment thread source/github-helpers/get-pr-info.ts Resolved
comparison: {
status: 'BEHIND' | 'DIVERGED' | 'AHEAD' | 'IDENTICAL';
};
};

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.

You can merge these into flat object, no need to have prInfo and comparison keys. While we're at it it can be simplified further, like setting diverged: true instead of matching strings outside

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.

While we're at it it can be simplified further, like setting diverged: true instead of matching strings outside

Can you explain this one more time I am not sure I understood what you said

Comment on lines +50 to 54
if (repository.pullRequest.headRef.compare.status !== 'DIVERGED') {
return;
}

return repository.pullRequest;

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.

This just mixes the logic of a specific feature with this generic get pr info function, which could return the PR info regardless of the need to update the PR.

I suggested returning diverged: true for both API calls, i.e. something like

Suggested change
if (repository.pullRequest.headRef.compare.status !== 'DIVERGED') {
return;
}
return repository.pullRequest;
return {
...repository.pullRequest,
diverged: repository.pullRequest.headRef.compare.status === 'DIVERGED'
};

And the logic just checks pr.diverged, or better yet pr.needsUpdate as a combination of mergeable and diverged


I suppose it's ok as is for now if it's tested, but it'll need to be changed eventually. 👍

@yakov116
yakov116 merged commit 987b566 into main Nov 1, 2022
@yakov116
yakov116 deleted the v4 branch November 1, 2022 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

3 participants