def explode(): root = GitRoot.root() for line in Git.git("status", "--porcelain").splitlines(): mode, filename = line.split() try: if mode == "??": Git.git("add", filename, cwd=root) Git.git("commit", filename, "-m", "[fold] %s" % filename, cwd=root) except Exception as e: print("ERROR: couldn't commit filename %s." % filename) print("ERROR:", e)
def _release(pulls, working_branch, next_branch, selector_name): Git.complete_reset() Delete.do_delete([working_branch], print=None) Git.copy_from_remote(base_branch(), working_branch, push=False) pulls.sort(key=operator.attrgetter('number')) if pulls: print('%s: Building release branch for %s:' % ( String.timestamp(), selector_name)) print(' ' + '\n '.join(str(p) for p in pulls)) print() success = [] failure = [] exceptions = [] for pull in pulls: try: print(pull.number, '...', sep='', end='') _pull_request(pull, working_branch) except VcxprojException: failure.append(pull.number) print('VCXPROJ...', end='') except Exception as e: failure.append(pull.number) print('ERROR...', end='') else: success.append(pull.number) if pulls: print() print() Version.version_commit( version_number=None, success=success, failure=failure) commit_id = Git.commit_id() Git.force_checkout(next_branch) Git.git('reset', '--hard', commit_id) Git.git('push', '-f') commits = Open.get_commits() plural = '' if len(commits) == 1 else 's' _print_pulls('Proposed new develop branch %s for pull%s' % (commits, plural), success) _print_pulls('FAILED:', failure) if success or failure: print('---------------------------------------------') print() else: print(String.timestamp(), ': no pulls ready.')
def _check_vcxproj(): # Now run scons vcxproj and see if anything changes. if not CHECK_VCXPROJ: return Call.runlines('scons vcxproj') status = Git.git('status') if not MATCH in status: # TODO: Check to see if src/soci/src/core/version.h is the only # difference. raise VcxprojException()
def version_commit(version_number=None, success=None, failure=None): root = GitRoot.root() files = Project.settings('version')['files'] old_version = get_version() if version_number == old_version: raise Exception('Version number is already %s' % old_version) if not version_number: version_number = semver.increment_string(old_version) if not CommandList.confirm('update version %s to %s' % (old_version, version_number)): return for f in files: File.subn(os.path.join(root, f), VERSION, version_number) if success or failure: ChangeLog.add_status_line(version_number, success, failure) Git.git('commit', '-am', 'Set version to %s' % version_number)
def clone(directory): settings = Project.settings("clone") branch = settings.get("base_branch", "develop") root = GitRoot.root(os.getcwd()) if root: directory = directory or os.path.basename(root) root = os.path.dirname(root) else: directory = directory or Settings.PROJECT root = os.getcwd() directory = File.next_version(os.path.join(root, directory)) settings.update(branch=branch, directory=directory, project=Settings.PROJECT, user=Settings.USER) # Call git clone. if Git.git(*_CLONE.format(**settings).split(), cwd=root): raise ValueError("Failed to start new directory") Remote.remote("all", cwd=directory) Remote.remote("upstream", Settings.PROJECT, directory) Git.git("pull", "upstream", branch) banner("Created", branch + ", directory", directory) return directory
def run_import(branch, **kwds): user, branch = parse_branch(branch) if branch not in Git.branch1es(user): raise ValueError(_BRANCH_ERROR.format(**locals())) if user == Settings.USER: Git.git('checkout', branch) else: Remote.remote(user, **kwds) Git.git('fetch', user, branch) Git.git('checkout', '-b', '/'.join([user, branch]))