@markjaquith/agency 1.9.3 → 1.9.4
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/push.test.ts +33 -0
- package/src/commands/push.ts +29 -43
package/package.json
CHANGED
|
@@ -115,6 +115,39 @@ describe("push command", () => {
|
|
|
115
115
|
expect(remoteBranches).toContain("feature")
|
|
116
116
|
})
|
|
117
117
|
|
|
118
|
+
test("forwards verbose output from emit step", async () => {
|
|
119
|
+
const originalLog = console.log
|
|
120
|
+
const logMessages: string[] = []
|
|
121
|
+
console.log = (msg: string) => {
|
|
122
|
+
logMessages.push(msg)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
await runTestEffect(
|
|
127
|
+
push({
|
|
128
|
+
baseBranch: "main",
|
|
129
|
+
verbose: true,
|
|
130
|
+
skipFilter: true,
|
|
131
|
+
}),
|
|
132
|
+
)
|
|
133
|
+
} finally {
|
|
134
|
+
console.log = originalLog
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
expect(logMessages).toContain("Step 1: Emitting...")
|
|
138
|
+
expect(
|
|
139
|
+
logMessages.some(
|
|
140
|
+
(msg) => msg.includes("Using base branch:") && msg.includes("main"),
|
|
141
|
+
),
|
|
142
|
+
).toBe(true)
|
|
143
|
+
expect(
|
|
144
|
+
logMessages.some((msg) =>
|
|
145
|
+
msg.includes("Skipping git-filter-repo (skipFilter=true)"),
|
|
146
|
+
),
|
|
147
|
+
).toBe(true)
|
|
148
|
+
expect(logMessages.some((msg) => msg.includes("Emitted"))).toBe(true)
|
|
149
|
+
})
|
|
150
|
+
|
|
118
151
|
test("works with custom branch name", async () => {
|
|
119
152
|
await runTestEffect(
|
|
120
153
|
push({
|
package/src/commands/push.ts
CHANGED
|
@@ -122,41 +122,36 @@ const pushCore = (gitRoot: string, options: PushOptions) =>
|
|
|
122
122
|
verboseLog(`Starting push workflow from ${highlight.branch(sourceBranch)}`)
|
|
123
123
|
|
|
124
124
|
// Step 1: Create emit branch (agency emit)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return yield* Effect.fail(
|
|
153
|
-
new Error(`Failed to create emit branch: ${message}`),
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
emitHadIgnorableFailure = true
|
|
158
|
-
verboseLog("Emit reported existing branch; continuing")
|
|
125
|
+
verboseLog("Step 1: Emitting...")
|
|
126
|
+
// Use the emit command for the entire emit step so push and emit stay in sync.
|
|
127
|
+
const prEffectWithOptions = emit({
|
|
128
|
+
baseBranch: options.baseBranch,
|
|
129
|
+
emit: options.emit || options.branch,
|
|
130
|
+
silent: options.silent,
|
|
131
|
+
force: options.force,
|
|
132
|
+
verbose: options.verbose,
|
|
133
|
+
skipFilter: options.skipFilter,
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
const prResult = yield* Effect.either(prEffectWithOptions)
|
|
137
|
+
if (Either.isLeft(prResult)) {
|
|
138
|
+
const error =
|
|
139
|
+
prResult.left instanceof Error
|
|
140
|
+
? prResult.left
|
|
141
|
+
: new Error(String(prResult.left))
|
|
142
|
+
const message = error.message || ""
|
|
143
|
+
const ignorable =
|
|
144
|
+
message === "" ||
|
|
145
|
+
message.includes("already exists") ||
|
|
146
|
+
message.includes("check if branch exists")
|
|
147
|
+
|
|
148
|
+
if (!ignorable) {
|
|
149
|
+
return yield* Effect.fail(
|
|
150
|
+
new Error(`Failed to create emit branch: ${message}`),
|
|
151
|
+
)
|
|
159
152
|
}
|
|
153
|
+
|
|
154
|
+
verboseLog("Emit reported existing branch; continuing")
|
|
160
155
|
}
|
|
161
156
|
|
|
162
157
|
// Compute the emit branch name (emit() command now stays on source branch)
|
|
@@ -164,15 +159,6 @@ const pushCore = (gitRoot: string, options: PushOptions) =>
|
|
|
164
159
|
const emitBranchName =
|
|
165
160
|
options.emit || options.branch || branchInfo.emitBranch
|
|
166
161
|
|
|
167
|
-
// If skipFilter, we skipped emit() so we must create the emit branch manually
|
|
168
|
-
if (options.skipFilter) {
|
|
169
|
-
yield* git.createOrResetBranch(gitRoot, emitBranchName, sourceBranch)
|
|
170
|
-
// Switch back to source branch for consistency
|
|
171
|
-
yield* git.checkoutBranch(gitRoot, sourceBranch)
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
log(done(`Emitted ${highlight.branch(emitBranchName)}`))
|
|
175
|
-
|
|
176
162
|
// Step 2: Push to remote (git push)
|
|
177
163
|
const remote = yield* getRemoteName(gitRoot)
|
|
178
164
|
verboseLog(
|