MCPcopy Create free account
hub / github.com/6pac/SlickGrid / gitPushUpstreamBranch

Function gitPushUpstreamBranch

scripts/git-utils.mjs:73–106  ·  view source on GitHub ↗
(remote = 'origin', { cwd, branch, dryRun })

Source from the content-addressed store, hash-verified

71 * @returns {Promise<any>}
72 */
73export async function gitPushUpstreamBranch(remote = 'origin', { cwd, branch, dryRun }) {
74 try {
75 const branchName = branch || 'master';
76 console.log(`Preparing to push branch "${branchName}" to remote "${remote}"`);
77
78 // If in dry run mode, just log the intended action
79 if (dryRun) {
80 console.log(`[DRY RUN] Would push ${branchName} to ${remote}`);
81 return;
82 }
83
84 // Push strategies
85 const pushStrategies = [
86 ['push', '-u', remote, branchName],
87 ['push', '--set-upstream', remote, branchName],
88 ['push', remote, branchName]
89 ];
90
91 for (const strategy of pushStrategies) {
92 try {
93 console.log(`$ git ${strategy.join(' ')}`);
94 return await execAsyncPiped('git', strategy, { cwd }, dryRun);
95 } catch (strategyError) {
96 console.warn(`❌ Push failed with strategy ${strategy.join(' ')}`,
97 strategyError.message || 'Unknown error');
98 }
99 }
100
101 throw new Error('All push strategies failed');
102 } catch (error) {
103 console.error('🚨 Upstream Push Error:', error.message);
104 throw error;
105 }
106}
107
108/**
109 * Check if there's anything uncommited

Callers 1

release.mjsFile · 0.90

Calls 1

execAsyncPipedFunction · 0.90

Tested by

no test coverage detected