creates the version branch and adds abort steps
496664
function checkoutVersionBranch () {
    exec(`git branch -q -D release/${newVersion}`);
    exec(`git checkout -q -b release/${newVersion}`);
    abortCmds.push('git checkout master');
    abortCmds.push(`git branch -D release/${newVersion}`);
  }
270758
public Ref createBranchAndCheckout(Git git, String branch) {
        try {
            return git.checkout()
                .setCreateBranch(true)
                .setName(branch)
                .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
                .call();
        } catch (GitAPIException e) {
            throw new IllegalStateException(e);
        }
    }
363629
def create version, sign: false
      @version = Versionaire::Version version
      fail Errors::Git, "Unable to tag without commits." unless git.commits?
      return if existing_tag?

      git_tag sign: sign
    end
429870
def for_commit(hash_id, cmd_options={})
      hg_to_array(["log -r 'descendants(?) and head()' --template '\n{branches}'", hash_id], {}, cmd_options) do |line|
        build_with_name_only(line)
      end.compact.uniq
    end
648859
def handle_branch(repo, **kwargs):
    """"""
    log.info('branch: %s %s' %(repo, kwargs))
    if type(repo) in [unicode, str]:
        path = os.path.join(repo, kwargs.get('name', 'Unnamed'))
        desc = kwargs.get('desc')
        branch = Repo.new(path=path, desc=desc, bare=True)
    else:
        name = kwargs.get('name')
        path = kwargs.get('path')
        if path and not name:
            name = os.path.basename(path)
        desc = kwargs.get('desc')
        branch = repo.branch(name=name, desc=desc)
    return branch.serialize()
1152779
def branch(version = Origen.app.version.prefixed)
      version = VersionString.new(version)
      version = version.prefixed if version.semantic?
      capture = false
      File.readlines("#{Origen.root}/doc/history").each do |line|
        line = line.strip
        if capture
          if capture && line =~ /^#+ .*(Selector|Branch): '(.*)'/
            return Regexp.last_match(2).gsub('\\', '')
          end
        else
          if line =~ /Tag:/
            line = line.gsub('\\', '')
            if line =~ /^#+ Tag: #{version}$/ ||
               line =~ />Tag: #{version}</
              capture = true
            end
          end
        end
      end
      nil
    end
1191461
def _branch(self, live_defs, node, path=""):
        

        irsb = self._irsb(node.state)
        path = path + " -> " + hex(irsb.addr)

        if isinstance(irsb, SimProcedure):
            self._simproc_map[irsb.addr] = repr(irsb)

        l.debug("--> Branch: running block 0x%x" % irsb.addr)
        block = self._make_block(irsb, live_defs)
        self._imarks.update(block._imarks)
        if block.stop == True:
            #l.debug(" ### Stopping at block 0x%x" % (irsb.addr))
            l.debug(" ### End of path %s" % path)
            return irsb.addr
        succ = self._vfg._graph.successors(node)

        defer = []
        for s in succ:
            # Consider fake returns last
            if self._vfg._graph.edge[node][s]['jumpkind'] == 'Ijk_FakeRet':
                defer.append(s)
                continue
            # We need to make a copy of the dict !
            self._branch(dict(block.live_defs), s, path)

            # We explore every other paths before taking fake rets.
            # Ideally, we want to take fake rets only when functions don't
            # return.
            for s in defer:
                self._branch(dict(block.live_defs), s, path)
86507
protected function checkoutLocalDeployBranch() {
    $this->taskExecStack()
      ->dir($this->deployDir)
      // Create new branch locally.We intentionally use stopOnFail(FALSE) in
      // case the branch already exists. `git checkout -B` does not seem to work
      // as advertised.
      // @todo perform this in a way that avoid errors completely.
      ->stopOnFail(FALSE)
      ->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_VERBOSE)
      ->exec("git checkout -b {$this->branchName}")
      ->run();
  }
7202
function(url, branch) {
  this.url = url;
  if (url.startsWith('https://api.github.com/repos/')) {
    this.path = url.substring(29);
    this.apiUrl = url;
  }
  else if (url.startsWith('https://github.com/')) {
    this.path = url.substring(19);
    this.apiUrl = 'https://api.github.com/repos/' + this.path;
  }
  else {
    throw new Error('Unsupported URL format: ' + url);
  }
  
  this.branch = branch ? branch : 'master';
  
  if (typeof window === 'undefined') {
    this.request = require('request');
    this.requestOptions = {headers: {'User-Agent': 'limberest'}};
  } 
  else {
    this.request = require('browser-request');
    this.requestOptions = {};
  }
}
1350312
def set_version(self, version, force=True):
        

        if version in self.versions:
            self._version = version
            if 'working' in self.repo.branch().stdout:
                if force:
                    logger.info('Found working branch. Removing...')
                    cmd = self.repo.checkout('master')
                    cmd = self.repo.branch('working', d=True)                    
                else:
                    logger.info('Found working branch from previous session. Use force=True to remove it and start anew.')
                    return

            stdout = self.repo.checkout(version, b='working').stdout  # active version set in 'working' branch
            logger.info('Version {0} set'.format(version))
        else:
            raise AttributeError('Version {0} not found'.format(version))
289919
def bump_repos_version(module_name, new_version, local_only):
    
    # Make the cloning directory and change directories into it.
    tmp_dir = tempfile.mkdtemp(dir=os.getcwd())

    # Iterate through each repository.
    for owner, repo_name in REPOS_TO_CHANGE:
        repo_url = REPO_URL_FORMAT.format(owner, repo_name)

        gh = GitHubApiUtils(owner, repo_name)

        os.chdir(tmp_dir)

        # Clone the repo.
        ret_code = subprocess.call(['git', 'clone', '{}.git'.format(repo_url)])
        if ret_code:
            logging.error('Failed to clone repo {}'.format(repo_url))
            continue

        # Change into the cloned repo dir.
        os.chdir(repo_name)

        # Create a branch, using the version number.
        branch_name = '{}/{}'.format(module_name, new_version)
        ret_code = subprocess.call(['git', 'checkout', '-b', branch_name])
        if ret_code:
            logging.error('Failed to create branch in repo {}'.format(repo_url))
            continue

        # Search through all TXT files to find all lines with the module name, changing the pinned version.
        files_changed = False
        for root, _dirs, files in os.walk('.'):
            for file in files:
                if file.endswith('.txt') and (('requirements' in file) or ('requirements' in root)):
                    found = False
                    filepath = os.path.join(root, file)
                    with open(filepath) as f:
                        if '{}=='.format(module_name) in f.read():
                            found = True
                    if found:
                        files_changed = True
                        # Change the file in-place.
                        for line in fileinput.input(filepath, inplace=True):
                            if '{}=='.format(module_name) in line:
                                print '{}=={}'.format(module_name, new_version)
                            else:
                                print line,

        if not files_changed:
            # Module name wasn't found in the requirements files.
            logging.info("Module name '{}' not found in repo {} - skipping.".format(module_name, repo_url))
            continue

        # Add/commit the files.
        ret_code = subprocess.call(['git', 'commit', '-am', 'Updating {} requirement to version {}'.format(module_name, new_version)])
        if ret_code:
            logging.error("Failed to add and commit changed files to repo {}".format(repo_url))
            continue

        if local_only:
            # For local_only, don't push the branch to the remote and create the PR - leave all changes local for review.
            continue

        # Push the branch.
        ret_code = subprocess.call(['git', 'push', '--set-upstream', 'origin', branch_name])
        if ret_code:
            logging.error("Failed to push branch {} upstream for repo {}".format(branch_name, repo_url))
            continue

        # Create a PR with an automated message.
        rollback_branch_push = False
        try:
            # The GitHub "mention" below does not work via the API - unfortunately...
            response = gh.create_pull(
                title='Change {} version.'.format(module_name),
                body='Change the required version of {} to {}.\n\n@edx-ops/pipeline-team Please review and tag appropriate parties.'.format(module_name, new_version),
                head=branch_name,
                base='master'
            )
        except:
            logging.error('Failed to create PR for repo {} - did you set GITHUB_TOKEN?'.format(repo_url))
            rollback_branch_push = True
        else:
            logging.info('Created PR #{} for repo {}: {}'.format(response.number, repo_url, response.html_url))

        if rollback_branch_push:
            # Since the PR creation failed, delete the branch in the remote repo as well.
            ret_code = subprocess.call(['git', 'push', 'origin', '--delete', branch_name])
            if ret_code:
                logging.error("ROLLBACK: Failed to delete upstream branch {} for repo {}".format(branch_name, repo_url))

    if not local_only:
        # Remove the temp directory containing all the cloned repos.
        shutil.rmtree(tmp_dir)
161666
def on_branch(node, compiled_grammar)
      steps = process(node.children[0], compiled_grammar)

      if node.children[1]
        code = process(node.children[1], compiled_grammar)
      else
        code = nil
      end

      return Branch.new(steps, node.source_line, code)
    end
780773
def _make_version(major, minor, micro, releaselevel, serial):
    """"""
    assert releaselevel in ['alpha', 'beta', 'candidate', 'final']
    version = "%d.%d" % (major, minor)
    if micro:
        version += ".%d" % (micro,)
    if releaselevel != 'final':
        short = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc'}[releaselevel]
        version += "%s%d" % (short, serial)
    return version
179765
def update_version(self, version, step=1):
        ""

        # update the version based on the flags passed.
        if self.config.patch:
            version.patch += step
        if self.config.minor:
            version.minor += step
        if self.config.major:
            version.major += step
        if self.config.build:
            version.build_number += step
        if self.config.build_number:
            version.build_number = self.config.build_number

        # create a new tag in the repo with the new version.
        if self.config.dry_run:
            log.info('Not updating repo to version {0}, because of --dry-run'.format(version))
        else:
            version = self.call_plugin_function('set_version', version)

        return version
1230485
def needs_abort():
    
    for line in status().splitlines():
        if '--abort' in line:
            for part in line.split('"'):
                if '--abort' in part:
                    return part
        elif 'All conflicts fixed but you are still merging' in line:
            return 'git merge --abort'
        elif 'You have unmerged paths.' in line:
            return 'git merge --abort'
        elif 'all conflicts fixed: run "git rebase --continue"' in line:
            return 'git rebase --abort'
    return None
1369770
def _release(level):
    """"""
    version, comment = _new_version(level)

    if version is not None:

        run(['git',
             'commit',
             str(VER_PATH.relative_to(BASE_PATH)),
             str(CHANGES_PATH.relative_to(BASE_PATH)),
             '--amend',
             '--no-edit',
             ])
        run(['git',
             'tag',
             '-a',
             'v' + version,
             '-m',
             '"' + comment + '"',
             ])
        run(['git',
             'push',
             'origin',
             '--tags',
             ])
        run(['git',
             'push',
             'origin',
             'master',
             '-f',
             ])
1006093
def update():
    # type: () -> None
    
    branch = git.current_branch(refresh=True)
    develop = conf.get('git.devel_branch', 'develop')

    common.assert_branch_type('feature')
    common.git_checkout(develop)
    common.git_pull(develop)
    common.git_checkout(branch.name)
    common.git_merge(branch.name, develop)