This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const minimist = require("minimist"); | |
const chalk = require("chalk"); | |
const log = console.log; | |
const error = chalk.bold.red; | |
const debug = chalk.bold.green; | |
const info = chalk.rgb(215, 135, 95); | |
/* argv has all the user arguements | |
* Visit https://github.com/substack/minimist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Need to add refs and then fetch, as Jenkins does not allow to fetch other barnches | |
*/ | |
async function fetchBaseBranch(baseBranch) { | |
try { | |
console.log("Fetching ${baseBranch} from remote"); | |
const addBaseRefs = `git config --add remote.origin.fetch +refs/heads/${baseBranch}:refs/remotes/origin/${baseBranch}`; | |
const fetchBase = `git fetch --no-tags origin +refs/heads/${baseBranch}:refs/remotes/origin/${baseBranch}`; | |
const command = `${addBaseRefs} && ${fetchBase}`; | |
await exec(command); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Only works if github cli is installed and logged in | |
*/ | |
function getPRDetails() { | |
exec("gh pr view").then( | |
stdout => { | |
const response = stdout.toString(); | |
const prDetails = response.match(/into (\S+) from (\S+)/i); | |
const [, baseBranch, targetBranch] = prDetails; | |
console.log("Base branch: ", baseBranch); |
NewerOlder