def remove_issue(self): issue_key = input('Enter issue key: ') try: issue = self.jira_api.get_issue(issue_key) except JiraConnectionError: print(styled('Jira connection error', bcolors.ERROR)) except JiraError: print(styled('Issue not found', bcolors.ERROR)) else: self.commits_manager.remove_issue(issue)
def get_fix_version_issues(self): jql = 'project = ' + self.project['key'] + ' AND fixVersion = ' + self.fix_version['name'] issues = self.jira_api.get_issues(jql) if len(issues) == 0: exit(styled('Issues for selected fix version not found', bcolors.ERROR)) return False return issues
def modify_current_branch(self): if not self.project or not self.bb_project or not self.repo: print(styled('Select jira project, bitbucket project and bitbucket repostiory', bcolors.ERROR)) return commits_controller = CommitsController( self.jira_api, self.bitbucket_api, self.bb_project, self.project, self.repo ) commits_controller.run()
def make_release_branch(self): if not self.project or not self.bb_project or not self.repo: print(styled('Select jira project, bitbucket project and bitbucket repostiory', bcolors.ERROR)) return self.select_fix_version() commits_controller = CommitsController( self.jira_api, self.bitbucket_api, self.project, self.bb_project, self.repo, self.fix_version ) commits_controller.run()
def cherry_pick(self): subprocess.call(['git', 'cherry-pick', '--abort']) subprocess.call(['git', 'fetch']) if self.fix_version: branch = 'release/' + self.fix_version['name'] answer = input(styled('WARNING! Your local branch ' + branch + ' was deleted [y/n]', bcolors.WARNING)) if answer != 'y' and answer != 'Y': return subprocess.call(['git', 'checkout', 'master']) subprocess.call(['git', 'pull', 'origin', 'master']) subprocess.call(['git', 'branch', '-D', branch]) subprocess.call(['git', 'checkout', '-b', branch]) else: answer = input(styled('WARNING! Cherry-pick apply for current branch [y/n]', bcolors.WARNING)) if answer != 'y' and answer != 'Y': return release_commits = list(reversed(self.commits_manager.get_available_commits_ids())) subprocess.call(['git', 'cherry-pick', '--ff'] + release_commits) exit()
def get_commits(self): params = { 'until': self.branch_from, 'since': self.branch_to, 'merges': 'exclude', 'limit': 10000 } try: commits = self.bitbucket_api.get_commits(self.bb_project['key'], self.repo['slug'], params) except BitbucketConnectionError: exit(styled('Bitbucket connection failed', bcolors.ERROR)) return False except BitbucketError: exit(styled('Commits not found', bcolors.ERROR)) return False if len(commits) == 0: exit(styled('Commits in selected repository not found', bcolors.ERROR)) return False return commits
def run(self): print(styled('Bitbucket tools', bcolors.HEADER)) if settings.LOGIN and settings.PASSWORD: self.jira_login() if settings.PROJECT: self.select_jira_project() if settings.BITBUCKET_PROJECT: self.select_bitbucket_project() if settings.BITBUCKET_REPOSITORY: self.select_bitbucket_repo() while True: menu = self.get_menu() answer = self.show_menu(menu) menu[answer]['command']()
def error(self, message): exit(styled(message, bcolors.ERROR))