From a0463f45fcf859a03331b3a50a6f97b6762be7dc Mon Sep 17 00:00:00 2001 From: Itay Maman <94941+imaman@users.noreply.github.com> Date: Sun, 29 Mar 2026 12:32:39 +0300 Subject: [PATCH 1/4] rename branch to PR number --- src/dcc-cli.ts | 4 +++- src/git-ops.ts | 4 ++++ src/github-ops.ts | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dcc-cli.ts b/src/dcc-cli.ts index 8cde2c2..b3ef89b 100644 --- a/src/dcc-cli.ts +++ b/src/dcc-cli.ts @@ -208,7 +208,9 @@ async function push(args: { title?: string; submit?: boolean }) { if (currentPr) { await githubOps.updatePrTitle(currentPr.number, args.title) } else { - await githubOps.createPr(args.title) + const prNumber = await githubOps.createPr(args.title) + await gitOps.renameBranch(String(prNumber)) + print(`Local branch renamed to ${prNumber}`) } if (!args.submit) { diff --git a/src/git-ops.ts b/src/git-ops.ts index 6ac5578..72485eb 100644 --- a/src/git-ops.ts +++ b/src/git-ops.ts @@ -219,6 +219,10 @@ export class GitOps { await this.git.raw(['commit', '-m', message]) } + async renameBranch(newName: string): Promise { + await this.git.branch(['-m', newName]) + } + async deleteBranch(branchName: string): Promise { await this.git.branch(['-D', branchName]) } diff --git a/src/github-ops.ts b/src/github-ops.ts index 06ff3bf..9df74da 100644 --- a/src/github-ops.ts +++ b/src/github-ops.ts @@ -63,7 +63,7 @@ export class GithubOps { const b = await this.gitOps.getRepo() await this.kit.pulls.update({ owner: b.owner, repo: b.name, pull_number: prNumber, title: newTitle }) } - async createPr(title: string): Promise { + async createPr(title: string): Promise { const b = await this.gitOps.getBranch() const r = await this.gitOps.getRepo() @@ -104,5 +104,7 @@ export class GithubOps { issue_number: issueNumber, labels: this.prLabels, }) + + return issueNumber } } From ee753105628fb770e76aabb54051719f5ecfb9f9 Mon Sep 17 00:00:00 2001 From: Itay Maman <94941+imaman@users.noreply.github.com> Date: Sun, 29 Mar 2026 12:47:51 +0300 Subject: [PATCH 2/4] fix remote branch pr --- src/git-ops.ts | 10 ++++++++++ src/gql.ts | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/git-ops.ts b/src/git-ops.ts index 72485eb..22e07a7 100644 --- a/src/git-ops.ts +++ b/src/git-ops.ts @@ -85,6 +85,16 @@ export class GitOps { return bs.branches[bs.current] } + async getRemoteBranchName(): Promise { + try { + const out = await this.git.raw(['rev-parse', '--abbrev-ref', '@{upstream}']) + // origin/my-branch -> my-branch + return out.trim().replace(/^[^/]+\//, '') + } catch { + return undefined + } + } + async noUncommittedChanges(): Promise { const d = await this.git.diffSummary() if (d.files.length) { diff --git a/src/gql.ts b/src/gql.ts index a0906fb..0dd3110 100644 --- a/src/gql.ts +++ b/src/gql.ts @@ -46,6 +46,10 @@ export class GraphqlOps { } async getCurrentPr(): Promise { + const remoteBranch = await this.gitOps.getRemoteBranchName() + if (remoteBranch) { + return this.getPrOfBranch(remoteBranch) + } const b = await this.gitOps.getBranch() return this.getPrOfBranch(b.name) } From a974673aa87f12de91813b92aff15e449d4ce369 Mon Sep 17 00:00:00 2001 From: Itay Maman <94941+imaman@users.noreply.github.com> Date: Sun, 29 Mar 2026 12:51:24 +0300 Subject: [PATCH 3/4] _ --- src/dcc-config.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dcc-config.ts b/src/dcc-config.ts index 774a555..2fd404c 100644 --- a/src/dcc-config.ts +++ b/src/dcc-config.ts @@ -9,4 +9,5 @@ export const DccConfig = z.object({ openOn: z.enum(['github', 'graphite']).optional(), }) -export type DccConfig = z.infer // eslint-disable-line no-redeclare +// eslint-disable-next-line no-redeclare +export type DccConfig = z.infer From c321c6a761ab77503d011cb03d1e397de8b512e0 Mon Sep 17 00:00:00 2001 From: Itay Maman <94941+imaman@users.noreply.github.com> Date: Sun, 29 Mar 2026 12:55:04 +0300 Subject: [PATCH 4/4] keepremotebranch --- src/git-ops.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/git-ops.ts b/src/git-ops.ts index 22e07a7..3ea3cc7 100644 --- a/src/git-ops.ts +++ b/src/git-ops.ts @@ -230,7 +230,11 @@ export class GitOps { } async renameBranch(newName: string): Promise { + const remoteBranch = await this.getRemoteBranchName() await this.git.branch(['-m', newName]) + if (remoteBranch) { + await this.git.branch(['--set-upstream-to', `origin/${remoteBranch}`]) + } } async deleteBranch(branchName: string): Promise {