Exemple #1
0
    def write_patch_for_issue(self, issue_id=None):
        """
        Start a patch

        This is intended to be the first step in a process of providing
        a patch.
        Every patch should be written in its own branch. Therefore we
        provide a simple cmd to create a meaningfull named branch related to
        its issue. Thats why the issue id must be provided.
        There some consistency checks around starting a new branch.
        """

        __ret = []

        # first we have to do a few consistency checks
        if not check_string_to_int(issue_id):
            __ret.append(('WARNING', "ID must be an integer", 1))
            return __ret

        issue_id = int(issue_id)

        if not git.is_git_repo():
            __ret.append(('WARNING', "Not a git repository", 1))
            return __ret

        if not git.branch_is_clean():
            __ret.append((
                'WARNING',
                "Your branch is not clean. Please commit your changes first."))
            return __ret

        # Transform iid to id
        try:
            issue_uid = self.api.issue_iid_to_uid(issue_id)

            issue = self.api.getprojectissue(self.p_id, issue_uid)
            if not issue:
                __ret.append(('WARNING', "Issue ID not found", 1))
                return __ret

            if issue['project_id'] != self.p_id:
                __ret.append((
                    'WARNING',
                    "The issue ID does not correspond to the current " +
                    "git repository/project", 1))
                return __ret
        except TypeError as e:
            __ret.append(('FAIL', 'Something went wrong: {0}'. format(e.message)))
            return __ret

        # the workflow itself:
        # 1. create a branch
        # 2. switch to that branch.
        git.change_or_create_branch("issue_" + str(issue_id))
        return __ret
Exemple #2
0
    logging.captureWarnings(True)

if __name__ == '__main__':
    arguments = docopt(__doc__, version='nacl-git version 0.1')
    # print(arguments)

# Before we do anything else, we check, if nacl will possibly work.
init_nacl()


# list all git repositories
if arguments['list'] or arguments['l']:
    list_salt_git_repositories()

if arguments['branch'] or arguments['b']:
    change_or_create_branch(arguments['BRANCH'])

if arguments['checkout'] or arguments['c']:
    checkout_branch(arguments['BRANCH'])

if arguments['mergeall']:
    merge_all_repositories()

if arguments['merge'] or arguments['m']:
    merge_single_repository()

if arguments['prune'] or arguments['pr']:
    remote_prune()

if arguments['remote-diff'] or arguments['rd']:
    remote_diff()