mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-28 03:55:02 +03:00
fix: simplify pushAndCreate logic
This commit is contained in:
parent
af8955ccf1
commit
d4b60d0bc3
@ -73,7 +73,7 @@
|
||||
}
|
||||
|
||||
function handleOpenPR() {
|
||||
prDetailsModal?.show({ pushAndCreatePr: false });
|
||||
prDetailsModal?.show(false);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
}
|
||||
|
||||
function handleOpenPR(pushAndCreatePr: boolean = false) {
|
||||
prDetailsModal?.show({ pushAndCreatePr, name: currentSeries.name });
|
||||
prDetailsModal?.show(pushAndCreatePr);
|
||||
}
|
||||
|
||||
function editTitle(title: string) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
title: string;
|
||||
body: string;
|
||||
draft: boolean;
|
||||
seriesName?: string;
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -99,8 +98,7 @@
|
||||
let aiConfigurationValid = $state<boolean>(false);
|
||||
let aiDescriptionDirective = $state<string | undefined>(undefined);
|
||||
let showAiBox = $state<boolean>(false);
|
||||
let pushAndCreate = $state(false);
|
||||
let seriesName = $state('');
|
||||
let pushBeforeCreatePr = $state(false);
|
||||
|
||||
async function handleToggleUseTemplate() {
|
||||
if (!templateSelector) return;
|
||||
@ -157,7 +155,7 @@
|
||||
try {
|
||||
let upstreamBranchName = upstreamName;
|
||||
|
||||
if (pushAndCreate || commits.some((c) => !c.isRemote)) {
|
||||
if (pushBeforeCreatePr || commits.some((c) => !c.isRemote)) {
|
||||
const firstPush = !branch.upstream;
|
||||
const pushResult = await branchController.pushBranch(
|
||||
branch.id,
|
||||
@ -165,10 +163,6 @@
|
||||
props.type === 'preview-series'
|
||||
);
|
||||
|
||||
if (pushAndCreate) {
|
||||
upstreamBranchName = seriesName;
|
||||
}
|
||||
|
||||
if (pushResult) {
|
||||
upstreamBranchName = getBranchNameFromRef(pushResult.refname, pushResult.remote);
|
||||
}
|
||||
@ -309,9 +303,11 @@
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
export function show({ pushAndCreatePr = false, name = '' }) {
|
||||
pushAndCreate = pushAndCreatePr;
|
||||
seriesName = name;
|
||||
/**
|
||||
* @param {boolean} pushAndCreate - Whether or not the commits need pushed before opening a PR
|
||||
*/
|
||||
export function show(pushAndCreate = false) {
|
||||
pushBeforeCreatePr = pushAndCreate;
|
||||
modal?.show();
|
||||
}
|
||||
|
||||
@ -447,9 +443,8 @@
|
||||
type="submit"
|
||||
onclick={async () => await handleCreatePR(close)}
|
||||
>
|
||||
{isDraft
|
||||
? 'Create pull request draft'
|
||||
: `${pushAndCreate ? 'Push and ' : ''}Create pull request`}
|
||||
{pushBeforeCreatePr ? 'Push and ' : ''}
|
||||
{isDraft ? 'Create pull request draft' : `Create pull request`}
|
||||
|
||||
{#snippet contextMenuSlot()}
|
||||
<ContextMenuSection>
|
||||
|
Loading…
Reference in New Issue
Block a user