コード例 #1
0
ファイル: commons.py プロジェクト: pombredanne/continuity
def get_commands(tracker=None):
    """Get the available continuity commands.

    :param tracker: Default `None`. The tracker to get commands for. Lookup
        based on git configuration if not specified.
    """
    ret_val = {
        CommitCommand.name: CommitCommand,
        InitCommand.name: InitCommand,
    }

    try:
        git = GitService()

        if not tracker:
            continuity = git.get_configuration("continuity")
            tracker = continuity.get("tracker")

        if tracker == "github":
            from .github import (FinishCommand, IssueCommand, IssuesCommand,
                    ReviewCommand, StartCommand, TasksCommand)

            ret_val.update({
                FinishCommand.name: FinishCommand,
                IssueCommand.name: IssueCommand,
                IssuesCommand.name: IssuesCommand,
                ReviewCommand.name: ReviewCommand,
                StartCommand.name: StartCommand,
                TasksCommand.name: TasksCommand
            })
        else:
            from .pt import (BacklogCommand, FinishCommand, ReviewCommand,
                    StoryCommand, StartCommand, TasksCommand)

            ret_val.update({
                BacklogCommand.name: BacklogCommand,
                FinishCommand.name: FinishCommand,
                ReviewCommand.name: ReviewCommand,
                StoryCommand.name: StoryCommand,
                StartCommand.name: StartCommand,
                TasksCommand.name: TasksCommand
            })
    except GitException:
        from .commons import (FinishCommand, ReviewCommand, StartCommand,
                TasksCommand)

        ret_val.update({
            FinishCommand.name: FinishCommand,
            ReviewCommand.name: ReviewCommand,
            StartCommand.name: StartCommand,
            TasksCommand.name: TasksCommand
        })

    return ret_val
コード例 #2
0
ファイル: __init__.py プロジェクト: pombredanne/continuity
    def exclusive(self):
        """Determine if continuity is operating in exclusive mode.
        """
        ret_val = getattr(self, "assignedtoyou", False) or \
            getattr(self, "mywork", False)

        if ret_val is False:
            try:
                git = GitService()
                configuration = git.get_configuration("continuity")
                ret_val = configuration.get("exclusive", False)
            except GitException:
                pass

        return ret_val
コード例 #3
0
    def __call__(self):
        """Call this commit command.
        """
        try:
            git = GitService()

            if git.branch:
                configuration = git.get_configuration("branch",
                        git.branch.name)

                if configuration:
                    continuity = git.get_configuration("continuity")
                    tracker = continuity.get("tracker")

                    try:
                        if tracker == "jira":
                            mention = configuration["issue"]
                        else:
                            if continuity.get("tracker") == "github":
                                number = configuration["issue"]
                            else:
                                number = configuration["story"]

                            mention = "#{0}".format(number)

                        with open(self.namespace.file, 'r') as file:
                            message = file.read()

                        if mention not in message:
                            if tracker == "jira":
                                message = "{0} #comment {1}".format(mention,
                                    message)
                            else:
                                message = "[{0}] {1}".format(mention, message)

                            with open(self.namespace.file, 'w') as file:
                                file.write(message)
                    except KeyError:
                        exit()
                else:
                    exit()
            else:
                exit()
        except GitException:
            exit()