@markjaquith/agency 0.7.1 → 0.7.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.
- package/package.json +1 -1
- package/src/services/GitService.ts +44 -1
package/package.json
CHANGED
|
@@ -364,7 +364,7 @@ export class GitService extends Effect.Service<GitService>()("GitService", {
|
|
|
364
364
|
const configBranch = yield* getGitConfigEffect(
|
|
365
365
|
"agency.mainBranch",
|
|
366
366
|
gitRoot,
|
|
367
|
-
)
|
|
367
|
+
).pipe(Effect.catchAll(() => Effect.succeed(null)))
|
|
368
368
|
const mainBranch =
|
|
369
369
|
configBranch || (yield* findMainBranchEffect(gitRoot))
|
|
370
370
|
|
|
@@ -383,6 +383,49 @@ export class GitService extends Effect.Service<GitService>()("GitService", {
|
|
|
383
383
|
const strippedMainBranch =
|
|
384
384
|
mainBranch.match(/^[^/]+\/(.+)$/)?.[1] || mainBranch
|
|
385
385
|
|
|
386
|
+
// If currentBranch is empty (detached HEAD), check if HEAD points to main branch
|
|
387
|
+
if (!currentBranch) {
|
|
388
|
+
const headCommit = yield* runGitCommandOrFail(
|
|
389
|
+
["git", "rev-parse", "HEAD"],
|
|
390
|
+
gitRoot,
|
|
391
|
+
)
|
|
392
|
+
const headSha = headCommit.trim()
|
|
393
|
+
|
|
394
|
+
// Check if HEAD matches the configured main branch
|
|
395
|
+
const mainCommitResult = yield* spawnProcess(
|
|
396
|
+
["git", "rev-parse", mainBranch],
|
|
397
|
+
{ cwd: gitRoot },
|
|
398
|
+
)
|
|
399
|
+
if (
|
|
400
|
+
mainCommitResult.exitCode === 0 &&
|
|
401
|
+
headSha === mainCommitResult.stdout.trim()
|
|
402
|
+
) {
|
|
403
|
+
return false
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// If mainBranch doesn't have a remote prefix, also check the remote version
|
|
407
|
+
if (!mainBranch.includes("/")) {
|
|
408
|
+
const remote = yield* findDefaultRemoteEffect(gitRoot).pipe(
|
|
409
|
+
Effect.catchAll(() => Effect.succeed(null)),
|
|
410
|
+
)
|
|
411
|
+
if (remote) {
|
|
412
|
+
const remoteBranch = `${remote}/${mainBranch}`
|
|
413
|
+
const remoteCommitResult = yield* spawnProcess(
|
|
414
|
+
["git", "rev-parse", remoteBranch],
|
|
415
|
+
{ cwd: gitRoot },
|
|
416
|
+
)
|
|
417
|
+
if (
|
|
418
|
+
remoteCommitResult.exitCode === 0 &&
|
|
419
|
+
headSha === remoteCommitResult.stdout.trim()
|
|
420
|
+
) {
|
|
421
|
+
return false
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return true
|
|
427
|
+
}
|
|
428
|
+
|
|
386
429
|
// Current branch is not a feature branch if it matches either the full or stripped name
|
|
387
430
|
return (
|
|
388
431
|
currentBranch !== mainBranch && currentBranch !== strippedMainBranch
|