gitlab_mr.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:gitlab-merge-request 作者: anti-social 项目源码 文件源码
def edit_mr(data, source_project, target_project, commits):
    editor = os.environ.get('EDITOR', 'nano')
    title = data.get('title')
    assignee = data.get('assignee')
    description = data.get('description')
    content = (
        'Title:\n'
        '{title}\n'
        'Assignee:\n'
        '{assignee}\n'
        'Description:\n'
        '\n'
        '# You are creating a merge request:\n'
        '#\t{outline}\n'
        '#\n'
        '# Next commits will be included in the merge request:\n'
        '#\n'
        '{commits}\n'
        '#\n'
        '# Empty title will cancel the merge request.'
    ).format(
        title='{}\n'.format(title) if title else '',
        assignee='{}\n'.format(assignee) if assignee else '',
        description='{}\n'.format(description) if description else '',
        outline=get_mr_outline(data, source_project, target_project),
        commits=format_mr_commits(commits, prefix='#\t'),
    )
    with tempfile.NamedTemporaryFile() as tf:
        tf.write(content.encode('utf-8'))
        tf.flush()
        res = subprocess.run([editor, tf.name])
        tf.seek(0)
        new_data = data.copy()
        new_data.update(parse_mr_file(tf))
        return new_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号