Esempio n. 1
0
def start_create_pull_requests_workflow(github_issues, jira, assignee=None):
    # Create PR task if those are not created
    for issue in github_issues:
        pr_text = "pr_create#{issue.project}#{issue.id}".format(issue=issue)
        tasks = jira.search_existing_task(issue_text=pr_text)
        if len(tasks) > 1:
            print("Not a Valid Result! Found more than 1 tasks for"
                  " github {}".format(pr_text))
        elif len(tasks) == 1:  # Issue Already Exist, Check Assignee and Status
            echo_error("Updating PR task for .....{}".format(
                issue.data["html_url"]))
            update_existing_issue_in_current_sprint(tasks[0],
                                                    issue,
                                                    jira=jira,
                                                    issue_text=pr_text,
                                                    assignee=assignee)
        elif len(tasks) == 0:  # Create new issue in backlog.
            echo_error("Creating PR task for.....{}".format(
                issue.data["html_url"]))
            create_pull_request_in_current_sprint(issue,
                                                  jira=jira,
                                                  issue_text=pr_text,
                                                  assignee=assignee)
        else:
            print("Nothing Happened")
Esempio n. 2
0
def start_issue_workflow(github_issues, jira, assignee=None):
    # create issue if those are not created
    for issue in github_issues:
        issue_text = str("issue#" + issue.project + "#" + issue.id)
        tasks = jira.search_existing_task(issue_text=issue_text)
        if len(tasks) > 1:
            print("Not a Valid Result! Found more than 1 tasks for"
                  " github {}".format(issue_text))
        elif len(tasks) == 1:  # Issue Already Exist, Check Assignee and Status
            echo_error("Updating Issue task for .....{}".format(
                issue.data["html_url"]))
            update_existing_issue_in_current_sprint(
                tasks[0],
                issue,
                jira=jira,
                issue_text=issue_text,
            )
        elif len(tasks) == 0:  # Create new issue in backlog.
            echo_error("Creating Issue task for.....{}".format(
                issue.data["html_url"]))
            create_new_issue_in_backlog(issue,
                                        jira=jira,
                                        issue_text=issue_text,
                                        assignee=assignee)
        else:
            print("Nothing Happened")
Esempio n. 3
0
def print_issue_list(issue_list):
    echo_error("\n======================================="
               "Start Fetching"
               "=======================================")
    for issue_stat in issue_list:
        print("Title ==> " + issue_stat.title)
        print("Description ==> \n" + issue_stat.data["body"])
        print("Number ==> " + str(issue_stat.data["number"]))
        print("Assignees ==> " + str(len(issue_stat.data["assignees"])))
        print("Status ==> " + issue_stat.data["state"])
        print("URL ==> " + issue_stat.data["url"])
        print("Project ==> " + issue_stat.project)
        echo_error("===========================================")
Esempio n. 4
0
    def get_config_file(self, filename):
        """Look for the proper config file path based on
        https://github.com/omkarkhatavkar/jirasync/issues/5
        """
        # Try to find the file from path exported to JIRASYNC_SETTINGS_PATH
        # this variable can be a directory path like /foo/bar
        # and also can be full path like /etc/foo/config.yaml
        path = os.environ.get("JIRASYNC_SETTINGS_PATH")
        if path is not None:
            if not path.endswith(("yaml", "yml")):
                path = os.path.join(path, filename)
            if os.path.exists(path):
                echo_success("Found config file in {}".format(path))
                return path
            else:
                echo_error(
                    "JIRASYNC_SETTINGS_PATH={0} cannot be found".format(path))

        # Try to find in the XDG paths
        # look ~/.config/jirasync/config.yaml
        # then /etc/xdg/jirasync/config.yaml
        # then /etc/jirasync/config.yaml
        BaseDirectory.xdg_config_dirs.append("/etc")
        for dir_ in BaseDirectory.load_config_paths("jirasync"):
            path = os.path.join(dir_, filename)
            if os.path.exists(path):
                echo_success("Found config file in {}".format(path))
                return path

        # load from current directory
        path = os.path.join(os.curdir, filename)
        if os.path.exists(path):
            echo_success("Found config file in {}".format(path))
            return path

        raise IOError("{0} cannot be found".format(path))