codemodctl 0.1.33 → 0.1.35
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/dist/cli.mjs +36 -12
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -117,19 +117,43 @@ const createPrCommand = defineCommand({
|
|
|
117
117
|
console.error(error);
|
|
118
118
|
process.exit(1);
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
await
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
120
|
+
{
|
|
121
|
+
const headSha = await $`git rev-parse HEAD`;
|
|
122
|
+
const branchInfo = await $`git log --oneline -1`;
|
|
123
|
+
console.log(`Pushing HEAD=${headSha.stdout.trim()} (${branchInfo.stdout.trim()}) to refs/heads/${codemodBranchName}`);
|
|
124
|
+
const lsRemote = await $({ reject: false })`git -c http.version=HTTP/1.1 ls-remote origin refs/heads/${codemodBranchName}`;
|
|
125
|
+
console.log(`Remote ref: ${lsRemote.stdout.trim() || "(branch does not exist)"}`);
|
|
126
|
+
const maxRetries = 3;
|
|
127
|
+
let pushed = false;
|
|
128
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
129
|
+
const pushResult = await $({
|
|
130
|
+
env: process.env.DEBUG ? {
|
|
131
|
+
GIT_TRACE: "1",
|
|
132
|
+
GIT_CURL_VERBOSE: "1"
|
|
133
|
+
} : {},
|
|
134
|
+
reject: false
|
|
135
|
+
})`git -c http.version=HTTP/1.1 -c http.postBuffer=524288000 push origin HEAD:refs/heads/${codemodBranchName} --force`;
|
|
136
|
+
if (pushResult.exitCode === 0) {
|
|
137
|
+
pushed = true;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (pushResult.stderr?.includes("Everything up-to-date")) {
|
|
141
|
+
console.log("Branch already up-to-date on remote.");
|
|
142
|
+
pushed = true;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
console.error(`Push attempt ${attempt}/${maxRetries} failed (exit code ${pushResult.exitCode}):\n${pushResult.stderr}`);
|
|
146
|
+
if (attempt < maxRetries) {
|
|
147
|
+
const delay = attempt * 2e3;
|
|
148
|
+
console.log(`Retrying in ${delay / 1e3}s...`);
|
|
149
|
+
await new Promise((r) => setTimeout(r, delay));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (!pushed) {
|
|
153
|
+
console.error("Error: Failed to push changes after all retries");
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
128
156
|
console.log(`Pushed branch to origin: ${codemodBranchName}`);
|
|
129
|
-
} catch (error) {
|
|
130
|
-
console.error("Error: Failed to push changes");
|
|
131
|
-
console.error(error);
|
|
132
|
-
process.exit(1);
|
|
133
157
|
}
|
|
134
158
|
}
|
|
135
159
|
if (body) prData.body = body;
|