@ucdjs/release-scripts 0.0.0 → 0.1.0-beta.2

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.mjs +25 -2
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -342,6 +342,27 @@ async function rebaseBranch(ontoBranch, workspaceRoot) {
342
342
  await run("git", ["rebase", ontoBranch], { nodeOptions: { cwd: workspaceRoot } });
343
343
  }
344
344
  /**
345
+ * Check if local branch is ahead of remote (has commits to push)
346
+ * @param branch - The branch name to check
347
+ * @param workspaceRoot - The root directory of the workspace
348
+ * @returns Promise resolving to true if local is ahead, false otherwise
349
+ */
350
+ async function isBranchAheadOfRemote(branch, workspaceRoot) {
351
+ try {
352
+ const result = await run("git", [
353
+ "rev-list",
354
+ `origin/${branch}..${branch}`,
355
+ "--count"
356
+ ], { nodeOptions: {
357
+ cwd: workspaceRoot,
358
+ stdio: "pipe"
359
+ } });
360
+ return Number.parseInt(result.stdout.trim(), 10) > 0;
361
+ } catch {
362
+ return true;
363
+ }
364
+ }
365
+ /**
345
366
  * Check if there are any changes to commit (staged or unstaged)
346
367
  * @param workspaceRoot - The root directory of the workspace
347
368
  * @returns Promise resolving to true if there are changes, false otherwise
@@ -717,8 +738,10 @@ async function release(options) {
717
738
  console.log("Rebasing release branch onto", currentBranch);
718
739
  await rebaseBranch(currentBranch, workspaceRoot);
719
740
  await updatePackageJsonFiles(allUpdates);
720
- if (!await commitChanges("chore: update release versions", workspaceRoot)) {
721
- console.log("No changes to commit");
741
+ const hasCommitted = await commitChanges("chore: update release versions", workspaceRoot);
742
+ const isBranchAhead = await isBranchAheadOfRemote(releaseBranch, workspaceRoot);
743
+ if (!hasCommitted && !isBranchAhead) {
744
+ console.log("No changes to commit and branch is in sync with remote");
722
745
  await checkoutBranch(currentBranch, workspaceRoot);
723
746
  if (prExists) {
724
747
  console.log("No updates needed, PR is already up to date");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ucdjs/release-scripts",
3
- "version": "0.0.0",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "@ucdjs release scripts",
5
5
  "type": "module",
6
6
  "license": "MIT",