contribute-now 0.3.0 → 0.4.0-dev.c791252

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.
Files changed (2) hide show
  1. package/dist/index.js +21 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -205,6 +205,13 @@ async function branchExists(branch) {
205
205
  const { exitCode } = await run(["rev-parse", "--verify", branch]);
206
206
  return exitCode === 0;
207
207
  }
208
+ async function countCommitsAhead(branch, upstream) {
209
+ const { exitCode, stdout } = await run(["rev-list", "--count", `${upstream}..${branch}`]);
210
+ if (exitCode !== 0)
211
+ return 0;
212
+ const count = Number.parseInt(stdout.trim(), 10);
213
+ return Number.isNaN(count) ? 0 : count;
214
+ }
208
215
  async function fetchRemote(remote) {
209
216
  return run(["fetch", remote]);
210
217
  }
@@ -1994,7 +2001,7 @@ import pc7 from "picocolors";
1994
2001
  // package.json
1995
2002
  var package_default = {
1996
2003
  name: "contribute-now",
1997
- version: "0.3.0",
2004
+ version: "0.4.0-dev.c791252",
1998
2005
  description: "Git workflow CLI for squash-merge two-branch models. Keeps dev in sync with main after squash merges.",
1999
2006
  type: "module",
2000
2007
  bin: {
@@ -2897,6 +2904,19 @@ var start_default = defineCommand8({
2897
2904
  if (!await refExists(syncSource.ref)) {
2898
2905
  warn(`Remote ref ${pc11.bold(syncSource.ref)} not found. Creating branch from local ${pc11.bold(baseBranch)}.`);
2899
2906
  }
2907
+ const currentBranch = await getCurrentBranch();
2908
+ if (currentBranch === baseBranch && await refExists(syncSource.ref)) {
2909
+ const ahead = await countCommitsAhead(baseBranch, syncSource.ref);
2910
+ if (ahead > 0) {
2911
+ warn(`You are on ${pc11.bold(baseBranch)} with ${pc11.bold(String(ahead))} local commit${ahead > 1 ? "s" : ""} not in ${pc11.bold(syncSource.ref)}.`);
2912
+ info(" Syncing will discard those commits. Consider backing them up first (e.g. create a branch).");
2913
+ const proceed = await confirmPrompt("Discard local commits and sync to remote?");
2914
+ if (!proceed) {
2915
+ info("Aborted. Your local commits are untouched.");
2916
+ process.exit(0);
2917
+ }
2918
+ }
2919
+ }
2900
2920
  const updateResult = await updateLocalBranch(baseBranch, syncSource.ref);
2901
2921
  if (updateResult.exitCode !== 0) {
2902
2922
  if (await refExists(syncSource.ref)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contribute-now",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-dev.c791252",
4
4
  "description": "Git workflow CLI for squash-merge two-branch models. Keeps dev in sync with main after squash merges.",
5
5
  "type": "module",
6
6
  "bin": {