def repo(self, path=None): if isinstance(path, GitRepo): self._repo = path elif path is None: self._repo = GitRepo(self.conf.paths.projectroot) elif os.path.isdir(path): self._repo = GitRepo(path) else: self._repo = GitRepo(os.getcwd())
def cherry_pick(args): c = fetch_config(args) g = GitRepo(c.paths.projectroot) if c.runstate.git_branch is None: c.runstate.git_branch = g.current_branch() with g.branch(c.runstate.git_branch): g.cherry_pick(c.runstate.git_objects)
def pull_rebase(args): c = fetch_config(args) g = GitRepo(c.paths.projectroot) if c.runstate.git_branch is None: c.runstate.git_branch = g.current_branch() with g.branch(c.runstate.git_branch): g.update()
def apply_patch(args): c = fetch_config(args) g = GitRepo(c.paths.projectroot) if c.runstate.git_branch is None: c.runstate.git_branch = g.current_branch() with g.branch(c.runstate.git_branch): g.am( patches=c.runstate.git_objects, repo="/".join(["https://github.com", c.git.remote.upstream]), sign=c.runstate.git_sign_patch, )
def assets_setup(path, branch, repo): if os.path.exists(path): g = GitRepo(path) g.pull(branch=branch) logger.info('updated {0} repository'.format(path)) else: base, name = os.path.split(path) g = GitRepo(base) g.clone(repo, repo_path=name, branch=branch) logger.info('cloned {0} branch from repo {1}'.format(branch, repo))
def create_branch(args): """ Takes a single branch name and (if necessary) creates a new branch. Then, populates the ``build/<branch>`` directory for the new branch using either the parent branch or ``master``. Safe to run multiple times (after a rebase) to update the build cache from master. Also calls :method:`~giza.operations.build_env.fix_build_environment()` to tweak the new build output to update hashes and on-disk copies of the environment to prevent unnecessary full-rebuilds from sphinx. """ conf = fetch_config(args) g = GitRepo(conf.paths.projectroot) branch = conf.runstate.git_branch base_branch = g.current_branch() if base_branch == branch: base_branch = 'master' logger.warning( 'seeding build data for branch "{0}" from "master"'.format(branch)) branch_builddir = os.path.join(conf.paths.projectroot, conf.paths.output, branch) base_builddir = os.path.join(conf.paths.projectroot, conf.paths.output, base_branch) if g.branch_exists(branch): logger.info('checking out branch "{0}"'.format(branch)) else: logger.info( 'creating and checking out a branch named "{0}"'.format(branch)) g.checkout_branch(branch) cmd = "rsync -r --times --checksum {0}/ {1}".format( base_builddir, branch_builddir) logger.info('seeding build directory for "{0}" from "{1}"'.format( branch, base_branch)) command(cmd) logger.info('branch creation complete.') # get a new config here for the new branch conf = fetch_config(args) builders = get_existing_builders(conf) app = BuildApp(conf) app.pool = 'process' fix_build_env_tasks(builders, conf, app) app.run()
def apply_patch(args): c = fetch_config(args) g = GitRepo(c.paths.projectroot) if c.runstate.git_branch is None: c.runstate.git_branch = g.current_branch() with g.branch(c.runstate.git_branch): g.am(patches=c.runstate.git_objects, repo='/'.join(['https://github.com', c.git.remote.upstream]), sign=c.runstate.git_sign_patch)
def setup_branches(args): conf = fetch_config(args) g = GitRepo(c.paths.projectroot) if 'upstream' in g.remotes(): remote = 'upstream' else: remote = 'origin' for pbranch in conf.git.branches.published: if g.branch_exists(pbranch): continue else: tracking_branch = '/'.join([remote, pbranch]) g.create_branch(pbranch, tracking=tracking_branch) logger.info('created branch "{0}" tracking "{1}"'.format( pbranch, tracking_branch))
def merge(args): c = fetch_config(args) g = GitRepo(c.paths.projectroot) from_branch = g.current_branch() branch_name = str(id(c.runstate.git_branch)) g.checkout_branch(branch_name, c.runstate.git_branch) try: g.checkout(branch_name) g.rebase(from_branch) g.checkout(from_branch) g.merge(c.runstate.git_branch) logger.info('rebased and merged {0} into {1}'.format( c.runstate.git_branch, from_branch)) except Exception as e: logger.warning('error attempting to merge branch: ' + c.runstate.git_branch) logger.error(e) finally: if g.current_branch != from_branch: g.checkout(from_branch) g.remove_branch(branch_name, force=False)
def merge(args): c = fetch_config(args) g = GitRepo(c.paths.projectroot) from_branch = g.current_branch() branch_name = str(id(c.runstate.git_branch)) g.checkout_branch(branch_name, c.runstate.git_branch) try: g.checkout(branch_name) g.rebase(from_branch) g.checkout(from_branch) g.merge(c.runstate.git_branch) logger.info("rebased and merged {0} into {1}".format(c.runstate.git_branch, from_branch)) except Exception as e: logger.warning("error attempting to merge branch: " + c.runstate.git_branch) logger.error(e) finally: if g.current_branch != from_branch: g.checkout(from_branch) g.remove_branch(branch_name, force=True)