How to use the shipjs-lib.getCurrentBranch function in shipjs-lib

To help you get started, we’ve selected a few shipjs-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / shipjs / packages / shipjs / src / step / release / gitPush.js View on Github external
runStep({ title: 'Pushing to the remote.' }, () => {
    const currentBranch = getCurrentBranch(dir);
    const { mergeStrategy, remote } = config;
    const destinationBranch = getBranchNameToMergeBack({
      currentBranch,
      mergeStrategy,
    });
    if (currentBranch === destinationBranch) {
      gitPush({ remote, refs: [currentBranch, tagName], dir, dryRun });
    } else {
      // currentBranch: 'master'
      // destinationBranch: 'develop'
      // flow: develop -> master -> (here) develop
      run({ command: `git checkout ${destinationBranch}`, dir, dryRun });
      run({ command: `git merge ${currentBranch}`, dir, dryRun });
      gitPush({ remote, refs: [currentBranch, tagName], dir, dryRun });
    }
  });
github algolia / shipjs / packages / shipjs / src / helper / validateBeforePrepare.js View on Github external
export default function validateBeforePrepare({ dir, baseBranches } = {}) {
  const result = [];
  if (!isWorkingTreeClean(dir)) {
    result.push(WORKING_TREE_NOT_CLEAN);
  }
  if (baseBranches.indexOf(getCurrentBranch(dir)) === -1) {
    result.push(CURRENT_BRANCH_INCORRECT);
  }
  return result.length === 0 ? true : result;
}
github algolia / shipjs / packages / shipjs / src / step / release / validate.js View on Github external
runStep({ title: 'Checking the current status.' }, () => {
    const {
      mergeStrategy,
      formatPullRequestTitle,
      shouldRelease,
      monorepo,
    } = config;
    const commitMessage = getLatestCommitMessage(dir);
    const currentVersion =
      monorepo && monorepo.mainVersionFile
        ? getCurrentVersion(dir, monorepo.mainVersionFile)
        : getCurrentVersion(dir);
    const currentBranch = getCurrentBranch(dir);
    const validationResult = shouldRelease({
      commitMessage,
      currentVersion,
      currentBranch,
      mergeStrategy,
      formatPullRequestTitle,
    });
    if (validationResult !== true) {
      print(warning('Skipping a release due to the following reason:'));
      print(info(`  > ${validationResult}`));
      exitProcess(0);
    }
    return {
      currentVersion,
    };
  });
github algolia / shipjs / packages / shipjs / src / step / prepare / validate.js View on Github external
() => {
      const { mergeStrategy, monorepo } = config;
      const baseBranches = getBaseBranches({ mergeStrategy });
      const currentVersion =
        monorepo && monorepo.mainVersionFile
          ? getCurrentVersion(dir, monorepo.mainVersionFile)
          : getCurrentVersion(dir);
      const result = validateBeforePrepare({
        dir,
        baseBranches,
      });
      const baseBranch = getCurrentBranch(dir);
      if (result !== true) {
        printValidationError({
          result,
          baseBranches,
        });
        exitProcess(1);
      }
      return { currentVersion, baseBranch };
    }
  );