@docupace/pipeline 1.0.61-alpha.0 → 1.0.61-alpha.1
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/merge/cli-merge.js +29 -11
package/package.json
CHANGED
package/src/merge/cli-merge.js
CHANGED
|
@@ -179,6 +179,21 @@ async function createAndCommitChangeset(
|
|
|
179
179
|
/**
|
|
180
180
|
* Merge into target branch
|
|
181
181
|
*/
|
|
182
|
+
|
|
183
|
+
function branchExists(branchName) {
|
|
184
|
+
try {
|
|
185
|
+
// This will list branches that match the name
|
|
186
|
+
const result = execSync(`git branch --list ${branchName}`, {
|
|
187
|
+
encoding: 'utf8',
|
|
188
|
+
});
|
|
189
|
+
return result.trim().length > 0;
|
|
190
|
+
} catch (error) {
|
|
191
|
+
// If git fails, you can log or handle differently
|
|
192
|
+
console.error('Error checking branch:', error.message);
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
182
197
|
function mergeIntoTarget(
|
|
183
198
|
sourceBranch,
|
|
184
199
|
targetBranch,
|
|
@@ -192,20 +207,23 @@ function mergeIntoTarget(
|
|
|
192
207
|
stdio: verbose ? 'inherit' : 'pipe',
|
|
193
208
|
});
|
|
194
209
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
210
|
+
if (branchExists(mergeBranchName)) {
|
|
211
|
+
execSync(`git merge ${mergeBranchName}`, {
|
|
212
|
+
stdio: verbose ? 'inherit' : 'pipe',
|
|
213
|
+
});
|
|
198
214
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
215
|
+
execSync(`git push origin ${targetBranch}`, {
|
|
216
|
+
stdio: verbose ? 'inherit' : 'pipe',
|
|
217
|
+
});
|
|
202
218
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
});
|
|
219
|
+
execSync(`git branch -d ${mergeBranchName}`, {
|
|
220
|
+
stdio: verbose ? 'inherit' : 'pipe',
|
|
221
|
+
});
|
|
207
222
|
|
|
208
|
-
|
|
223
|
+
if (verbose) console.log(`✅ Successfully merged into ${targetBranch}`);
|
|
224
|
+
} else {
|
|
225
|
+
if (verbose) console.log(`✅ Nothing to merge`);
|
|
226
|
+
}
|
|
209
227
|
}
|
|
210
228
|
|
|
211
229
|
/**
|