Skip to content

Commit

Permalink
add push branch
Browse files Browse the repository at this point in the history
  • Loading branch information
yeager-eren committed Dec 30, 2023
1 parent 8121dc0 commit 27012e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
26 changes: 18 additions & 8 deletions scripts/common/git.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,24 @@ export async function addFileToStage(path) {
});
}

export async function push(remote = 'origin') {
const output = await execa('git', [
'push',
remote,
'--follow-tags',
'--no-verify',
'--atomic',
])
export async function push(options) {
const { steupRemote, branch, remote = 'origin' } = options;

const pushOptions = [];

if (steupRemote) {
if (!branch) {
throw new CustomScriptError(
`You should also pass branch name as parameter to push. \n ${error.stderr}`
);
}

pushOptions = ['--set-upstream', remote, branch];
} else {
pushOptions = [remote, '--follow-tags', '--no-verify', '--atomic'];
}

const output = await execa('git', ['push', ...pushOptions])
.then(({ stdout }) => stdout)
.catch((error) => {
throw new GitError(`git push failed. \n ${error.stderr}`);
Expand Down
9 changes: 7 additions & 2 deletions scripts/post-release/command.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { checkout, del, merge, pull, push } from '../common/git.mjs';
import { checkout, createAndSwitch, del, pull, push } from '../common/git.mjs';
import { checkCommitAndGetPkgs } from './tag.mjs';

async function run() {
Expand All @@ -13,11 +13,16 @@ async function run() {
await checkout('main');
await pull();

await checkCommitAndGetPkgs();
// await checkCommitAndGetPkgs();

// Making sure we are deleting the branch then create a new one.
// Note: it will fails silently since if a branch doesn't exist it goes through error.
await del(tempBranch);
await createAndSwitch(tempBranch);
await push({
setupRemote: true,
branch: tempBranch,
});
}

run().catch((e) => {
Expand Down

0 comments on commit 27012e8

Please sign in to comment.