def __call__(self, target): check_root() to_fetch = None if issue_tracker_tool.ISSUE_BE_LIKE.match(target) is None: # doesn't look like an issue to_fetch = [target] resolve_errors(git_tool.recurse_submodules(lambda: git_tool.fetch(to_fetch)), **FETCH_HANDLING) kind = None if all(x[1] for x in git_tool.recurse_submodules(lambda: git_tool.is_remote_branch(target))): kind = "branch" elif all(x[1] for x in git_tool.recurse_submodules(lambda: git_tool.is_tag(target))): kind = "tag" elif issue_tracker_tool.validate_issue(target) is not None: _target = target target = branchname_from_issue(target, test=True) kind = "branch" if target is None: print ("Can't find any matching branches. You probably didn't run 'new-feature'") do_new_feature = raw_input("Do you want to run it now [y/N]?") if do_new_feature in YES: new_feature(_target,labels=None) target = branchname_from_issue(_target) else: print RED("Please run new-feature first") sys.exit(1) if kind is not None: resolve_errors(git_tool.recurse_submodules(lambda: git_tool.checkout_remote(target, kind)), title="Checking out %s %s..." % (kind, target)) else: print "Failed to resolve target '%s'" % target
def __call__(self, namespace): check_root() branch = get_current_branch() authors = Counter() if is_squashed_branch(branch): print "You are trying to submit a squashed branch doll, go back to the original branch, it'll surely work!" return squashed_branch = append_squashed_branch_suffix(branch) issue = issue_from_branchname(branch) issue = issue_tracker_tool.validate_issue(issue) title = issue.fields.summary title = "%s: %s" % (issue.key, title) uninited_modules = git_tool.get_uninited_submodules() if uninited_modules: display_uninited_modules_instructions(uninited_modules) return resolve_errors(git_tool.recurse_submodules(lambda: git_tool.fetch(['master'])), **FETCH_HANDLING) resolve_errors(git_tool.recurse_submodules(lambda: git_tool.rebase_if_needed('master')), **REBASE_HANDLING) def get_original_author(): if git_tool.is_branch_diverged('origin/master'): authors[git_tool.get_author()] += 1 list(git_tool.recurse_submodules(get_original_author)) author = authors.most_common(1)[0][0] if authors else None def create_squashed_branch(): git_tool.gitcmd(['branch', '-f', squashed_branch, branch]) return git_tool.gitcmd(['checkout', squashed_branch]) def squash(): ret = err = None if git_tool.is_branch_diverged('origin/master'): ret, err = git_tool.squash(title, author) return ret, err def push_and_back(): git_tool.gitcmd(['checkout', branch]) return git_tool.forcepush(squashed_branch) resolve_errors(git_tool.recurse_submodules(git_tool.forcepush), title="Pushing...") resolve_errors(git_tool.recurse_submodules(create_squashed_branch), title="Creating squashed branch...") resolve_errors(git_tool.recurse_submodules(squash), title="Squashing...") resolve_errors(git_tool.fix_refs(), title="Fixing refs...") resolve_errors(git_tool.recurse_submodules(push_and_back), title="Pushing squashed branch...") self.process(namespace, squashed_branch)
def __call__(self, message, labels=None): check_root() if labels is None: labels = [] key = summary = None try: issue = issue_tracker_tool.validate_issue(message.strip().upper()) assert (issue is not None) summary = issue.fields.summary key = issue.key except Exception, e: print e message = issue_tracker_tool.process_message(message, labels) summary = message.summary key = message.issue issue = issue_tracker_tool.get_jira_server().issue(key)
def __call__(self): squashed_branch = os.environ.get('BRANCH') assignee = os.environ.get('ASSIGNEE') assigner = os.environ.get('BUILD_USER_ID') build_number = os.environ.get('BUILD_NUMBER') apk_path = os.environ.get('APK_PATH') # # must have all parameters to continue # if not(squashed_branch and assignee and assigner and build_number): # print RED("Cannot continue, got a missing environment variable BRANCH: {} ASSIGNEE: {} USER_ID: {} BUILD_NUMBER: {}" # .format(squashed_branch, assignee, assigner, build_number)) # return branch = strip_squashed_branch_suffix(squashed_branch) issue = issue_from_branchname(branch) issue = issue_tracker_tool.validate_issue(issue) title = issue.fields.summary title = "%s: %s" % (issue.key, title) self.process(assigner, assignee, build_number, issue, title, apk_path, squashed_branch)