

def _set_branch(self, branch, commit, checkout=False, force=False):
    if (str(self.repo.active_branch) == branch):
        self.log.info("\n                Resetting branch '%s' to specified commit '%s'\n                    git reset --hard %s\n                ", branch, commit, commit)
        self.git.reset(commit, hard=True)
    elif checkout:
        if force:
            checkout_opt = '-B'
        else:
            checkout_opt = '-b'
        self.log.info("\n                Checking out branch '%s' using specified commit '%s'\n                    git checkout %s %s %s\n                ", branch, commit, checkout_opt, branch, commit)
        self.git.checkout(checkout_opt, branch, commit)
    else:
        self.log.info("\n                Creating  branch '%s' from specified commit '%s'\n                    git branch --force %s %s\n                ", branch, commit, branch, commit)
        self.git.branch(branch, commit, force=force)

dataset/ETHPy150Open openstack/git-upstream/git_upstream/lib/importupstream.py ImportUpstream._set_branch/original