Пример #1
0
    def execute(self, context):
        r = requests.get(self.commits_link)
        json_obj = r.json()

        rewrite_date = lambda date: f'{date[:10]}' #  @ {date[11:16]}'

        # table boilerplate for github markdown
        print("author | commit details\n--- | ---")

        # intro message for Info printing
        messages = [f"The {self.num_commits} most recent commits to Sverchok (master)"]

        for i in range(self.num_commits):
            commit = json_obj[i]['commit']
            sha = os.path.basename(commit['url'])[:7]

            author = commit['author']['name']
            date = commit['author']['date'] #  format : '2021-04-03T10:44:59Z'
            comments = commit['message'].split('\n')
            comment = comments[0] + '...' if len(comments) else ''

            message = f'{author} | {comment} {sha} on {rewrite_date(date)}'
            print(message)
            messages.append(message)

        multiline_string_of_messages = "\n".join(messages)
        self.report({'INFO'}, multiline_string_of_messages)

        return {'FINISHED'}
Пример #2
0
    def execute(self, context):
        r = requests.get(
            'https://api.github.com/repos/nortikin/sverchok/commits')
        json_obj = r.json()
        for i in range(5):
            commit = json_obj[i]['commit']
            comment = commit['message'].split('\n')

            # display on report window
            message_dict = {
                'sha': os.path.basename(json_obj[i]['commit']['url'])[:7],
                'user': commit['committer']['name'],
                'comment': comment[0] + '...' if len(comment) else ''
            }

            self.report(
                {'INFO'},
                '{sha} : by {user}  :  {comment}'.format(**message_dict))

            # display on terminal
            print('{sha} : by {user}'.format(**message_dict))
            for line in comment:
                print('    ' + line)

        return {'FINISHED'}
Пример #3
0
def latest_github_sha(commits_link):
    """ get sha produced by latest commit on github

        sha = latest_github_sha()
        print(sha)

    """
    r = requests.get(commits_link)
    json_obj = r.json()
    return os.path.basename(json_obj[0]['commit']['url'])
Пример #4
0
def latest_github_sha():
    """ get sha produced by latest commit on github

        sha = latest_github_sha()
        print(sha)

    """
    r = requests.get('https://api.github.com/repos/nortikin/sverchok/commits')
    json_obj = r.json()
    return os.path.basename(json_obj[0]['commit']['url'])
Пример #5
0
def latest_github_sha():
    """ get sha produced by latest commit on github

        sha = latest_github_sha()
        print(sha)

    """
    r = requests.get('https://api.github.com/repos/nortikin/sverchok/commits')
    json_obj = r.json()
    return os.path.basename(json_obj[0]['commit']['url'])
Пример #6
0
    def execute(self, context):
        r = requests.get('https://api.github.com/repos/nortikin/sverchok/commits')
        json_obj = r.json()
        for i in range(5):
            commit = json_obj[i]['commit']
            comment = commit['message'].split('\n')

            # display on report window
            message_dict = {
                'sha': os.path.basename(json_obj[i]['commit']['url'])[:7],
                'user': commit['committer']['name'],
                'comment': comment[0] + '...' if len(comment) else ''
            }

            self.report({'INFO'}, '{sha} : by {user}  :  {comment}'.format(**message_dict))

            # display on terminal
            print('{sha} : by {user}'.format(**message_dict))
            for line in comment:
                print('    ' + line)

        return {'FINISHED'}