Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate list of all Merge Requests merged between two tags with all informations in csv file

I'm trying to do a csv file with all informations about merge requests merged between two tags. I'm trying to get this kind of information for each merge request:

UID; ID; TITLE OF MR; REPOSITORIES; STATUS; MILESTONE; ASSIGNED; CREATION-DATE; MERGED-DATE; LABEL; URL.

For now I have a command that get all merge requests merged between two tags with some informations and put it in csv file:

git log --merges --first-parent master --pretty=format:"%aD;%an;%H;%s;%b" TagA..TagB --shortstat >> MRList.csv

How can I get the other informations? I saw in the git log api only options in my command but I can't find others.

Thank you for your help !

like image 953
koce Avatar asked Oct 15 '25 14:10

koce


1 Answers

I've written a small Python script to do this. Usage:

git log --pretty="format:%H" <start>..<end> | python collect.py

Script:

#!/usr/bin/env python

import sys
import requests

endpoint = 'https://gitlab.com'
project_id = '4242'

mrs = set()
for line in sys.stdin:
    hash = line.rstrip('\n')
    r = requests.get(endpoint + '/api/v4/projects/' + project_id + '/repository/commits/' + hash + '/merge_requests')
    r.raise_for_status()
    for mr in r.json():
        if mr['state'] != 'merged':
            continue
        if mr['id'] in mrs:
            continue
        mrs.add(mr['id'])

        print('!{} {} ({})'.format(mr['iid'], mr['title'], mr['web_url']), flush=True)
like image 138
emersion Avatar answered Oct 17 '25 19:10

emersion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!