gh-stack 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/commands/submit.ts +17 -1
package/package.json
CHANGED
package/src/commands/submit.ts
CHANGED
|
@@ -45,6 +45,20 @@ function branchToTitle(branch: string): string {
|
|
|
45
45
|
return name.charAt(0).toUpperCase() + name.slice(1);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Check if a local branch is up-to-date with its remote counterpart.
|
|
50
|
+
*/
|
|
51
|
+
async function isBranchUpToDate(branch: string): Promise<boolean> {
|
|
52
|
+
try {
|
|
53
|
+
const localSha = (await $`git rev-parse ${branch}`.text()).trim();
|
|
54
|
+
const remoteSha = (await $`git rev-parse origin/${branch}`.text()).trim();
|
|
55
|
+
return localSha === remoteSha;
|
|
56
|
+
} catch {
|
|
57
|
+
// Remote branch doesn't exist yet
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
/**
|
|
49
63
|
* Push a branch to origin with upstream tracking and force-with-lease.
|
|
50
64
|
*/
|
|
@@ -105,9 +119,11 @@ export default async function submit(args: string[]): Promise<void> {
|
|
|
105
119
|
const branchMeta = stack.branches[branchName]!;
|
|
106
120
|
const parentBranch = branchMeta.parent;
|
|
107
121
|
|
|
108
|
-
// ── Push ──
|
|
122
|
+
// ── Push (skip if already up-to-date) ──
|
|
109
123
|
if (dryRun) {
|
|
110
124
|
p.log.step(`${pc.dim("push")} ${branchName} → origin/${branchName}`);
|
|
125
|
+
} else if (await isBranchUpToDate(branchName)) {
|
|
126
|
+
p.log.info(`${pc.dim("✓")} ${pc.blue(branchName)} already up to date`);
|
|
111
127
|
} else {
|
|
112
128
|
const s = p.spinner();
|
|
113
129
|
s.start(`Pushing ${pc.blue(branchName)}...`);
|