@panoptic-it-solutions/coolify-setup 1.1.27 → 1.1.29
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/git.js +84 -16
- package/package.json +1 -1
package/dist/git.js
CHANGED
|
@@ -45,7 +45,11 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
45
45
|
run('git init');
|
|
46
46
|
}
|
|
47
47
|
// Use passed-in branch name, or detect current branch
|
|
48
|
-
|
|
48
|
+
let sourceBranch = originalBranch || run('git branch --show-current');
|
|
49
|
+
// Handle detached HEAD state
|
|
50
|
+
if (!sourceBranch) {
|
|
51
|
+
sourceBranch = 'develop';
|
|
52
|
+
}
|
|
49
53
|
// Stage all specified files (use -A to also stage deletions)
|
|
50
54
|
for (const file of files) {
|
|
51
55
|
try {
|
|
@@ -143,8 +147,27 @@ export async function commitAndPushToDevelop(files, originalBranch) {
|
|
|
143
147
|
// Pull might fail, continue
|
|
144
148
|
}
|
|
145
149
|
// Merge the source branch (which has the commits)
|
|
146
|
-
|
|
150
|
+
try {
|
|
151
|
+
run(`git merge ${sourceBranch} --no-edit`);
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
// Merge conflict - abort and report
|
|
155
|
+
try {
|
|
156
|
+
run('git merge --abort');
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// Abort might fail, continue
|
|
160
|
+
}
|
|
161
|
+
throw new Error(`Merge conflict between develop and ${sourceBranch}. Please resolve manually.`);
|
|
162
|
+
}
|
|
147
163
|
run('git push origin develop');
|
|
164
|
+
// Return to original branch
|
|
165
|
+
try {
|
|
166
|
+
run(`git checkout ${sourceBranch}`);
|
|
167
|
+
}
|
|
168
|
+
catch {
|
|
169
|
+
// Might fail if worktree, that's ok - user is on develop
|
|
170
|
+
}
|
|
148
171
|
}
|
|
149
172
|
}
|
|
150
173
|
else {
|
|
@@ -215,27 +238,72 @@ export async function setupGitHub(projectName) {
|
|
|
215
238
|
}
|
|
216
239
|
// Ensure we're on develop branch and push to it
|
|
217
240
|
try {
|
|
218
|
-
const currentBranch = run('git branch --show-current');
|
|
241
|
+
const currentBranch = run('git branch --show-current') || 'develop';
|
|
219
242
|
if (currentBranch !== 'develop') {
|
|
220
|
-
//
|
|
243
|
+
// Try to checkout develop
|
|
244
|
+
let checkoutSucceeded = false;
|
|
221
245
|
try {
|
|
222
|
-
|
|
246
|
+
// Check if develop exists locally
|
|
247
|
+
try {
|
|
248
|
+
run('git rev-parse --verify develop');
|
|
249
|
+
run('git checkout develop');
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// Create develop from current branch
|
|
253
|
+
run('git checkout -b develop');
|
|
254
|
+
}
|
|
255
|
+
checkoutSucceeded = true;
|
|
223
256
|
}
|
|
224
257
|
catch {
|
|
225
|
-
//
|
|
226
|
-
|
|
258
|
+
// Checkout failed - might be worktree issue
|
|
259
|
+
// Try to push current branch to develop instead (if fast-forward possible)
|
|
260
|
+
try {
|
|
261
|
+
// First fetch to check if develop exists remotely
|
|
262
|
+
try {
|
|
263
|
+
run('git fetch origin develop');
|
|
264
|
+
// Check if current branch contains all develop commits (fast-forward possible)
|
|
265
|
+
run(`git merge-base --is-ancestor origin/develop ${currentBranch}`);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
// Either develop doesn't exist remotely, or can't fast-forward
|
|
269
|
+
// Try push anyway - will fail if develop exists and diverged
|
|
270
|
+
}
|
|
271
|
+
run(`git push origin ${currentBranch}:develop -u`);
|
|
272
|
+
result.developBranchCreated = true;
|
|
273
|
+
result.repoPushed = true;
|
|
274
|
+
// Skip the rest of develop push logic since we already pushed
|
|
275
|
+
checkoutSucceeded = false;
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
result.warnings.push('Failed to push develop branch (checkout failed, possibly worktree conflict or branches diverged)');
|
|
279
|
+
checkoutSucceeded = false;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (checkoutSucceeded) {
|
|
283
|
+
// Pull latest changes before pushing to avoid non-fast-forward errors
|
|
284
|
+
try {
|
|
285
|
+
run('git pull --rebase origin develop');
|
|
286
|
+
}
|
|
287
|
+
catch {
|
|
288
|
+
// Pull might fail if remote doesn't exist yet, that's ok
|
|
289
|
+
}
|
|
290
|
+
run('git push origin develop -u');
|
|
291
|
+
result.developBranchCreated = true;
|
|
292
|
+
result.repoPushed = true;
|
|
227
293
|
}
|
|
228
294
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
295
|
+
else {
|
|
296
|
+
// Already on develop
|
|
297
|
+
try {
|
|
298
|
+
run('git pull --rebase origin develop');
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
// Pull might fail if remote doesn't exist yet, that's ok
|
|
302
|
+
}
|
|
303
|
+
run('git push origin develop -u');
|
|
304
|
+
result.developBranchCreated = true;
|
|
305
|
+
result.repoPushed = true;
|
|
235
306
|
}
|
|
236
|
-
run('git push origin develop -u');
|
|
237
|
-
result.developBranchCreated = true;
|
|
238
|
-
result.repoPushed = true;
|
|
239
307
|
}
|
|
240
308
|
catch {
|
|
241
309
|
result.warnings.push('Failed to push develop branch');
|