Пример #1
0
    def comment_on(self, number):
        self.login()
        user, repo = self.repository
        issue = self.gh.issue(user, repo, number)

        name = ''
        status = self.SUCCESS

        # I need to handle this on Windows too somehow
        if not os.path.expandvars('$EDITOR'):
            print("$EDITOR not set")
            return self.FAILURE

        with mktmpfile('gh-issuecomment-') as fd:
            name = fd.name
            os.system('$EDITOR {0}'.format(fd.name))

        comment = issue.create_comment(open(name).read())
        if not comment:
            status = self.FAILURE
            print(
                'Comment creation failed. Comment stored at {0}'.format(name))
        else:
            print('Comment created successfully.  {0}'.format(
                comment.html_url))
            rmtmpfile(name)

        return status
Пример #2
0
    def run(self, options, args):
        self.get_repo(options)
        opts, args = self.parser.parse_args(args)

        if opts.help:
            parser.print_help()
            return self.SUCCESS

        if not opts.title:
            parser.error('create.issue requires a title')
            parser.print_help()
            return self.FAILURE

        self.login()

        # I need to handle this on Windows too somehow
        if not expandvars('$EDITOR'):
            print("$EDITOR not set")
            return self.FAILURE

        status = self.SUCCESS
        with mktmpfile('gh-newissue-') as fd:
            name = fd.name
            system('$EDITOR {0}'.format(fd.name))

        issue = self.repo.create_issue(opts.title, open(name).read())

        if not issue:
            status = self.FAILURE
            print("Issue file is at saved at {0}".format(name))
        else:
            print("#{0.number} {0.html_url}".format(issue))
            rmtmpfile(name)

        return status
Пример #3
0
    def comment_on(self, number):
        self.login()
        user, repo = self.repository
        issue = self.gh.issue(user, repo, number)

        name = ''
        status = self.SUCCESS

        # I need to handle this on Windows too somehow
        if not os.path.expandvars('$EDITOR'):
            print("$EDITOR not set")
            return self.FAILURE

        with mktmpfile('gh-issuecomment-') as fd:
            name = fd.name
            os.system('$EDITOR {0}'.format(fd.name))

        comment = issue.create_comment(open(name).read())
        if not comment:
            status = self.FAILURE
            print('Comment creation failed. Comment stored at {0}'.format(
                name))
        else:
            print('Comment created successfully.  {0}'.format(
                comment.html_url))
            rmtmpfile(name)

        return status
Пример #4
0
    def run(self, options, args):
        self.get_repo(options)
        opts, args = self.parser.parse_args(args)

        if opts.help:
            parser.print_help()
            return self.SUCCESS

        if not opts.title:
            print('issue.create requires a title')
            self.parser.print_help()
            return self.FAILURE

        self.login()

        # I need to handle this on Windows too somehow
        if not os.path.expandvars('$EDITOR'):
            print("$EDITOR not set")
            return self.FAILURE

        status = self.SUCCESS
        with mktmpfile('gh-newissue-') as fd:
            name = fd.name
            os.system('$EDITOR {0}'.format(fd.name))

        issue = self.repo.create_issue(opts.title, open(name).read())

        if not issue:
            status = self.FAILURE
            print("Issue file is at saved at {0}".format(name))
        else:
            print("#{0.number} {0.html_url}".format(issue))
            rmtmpfile(name)

        return status