pythongitgitpythonpython-gitlab

How can I get information from Git about metadata changes over a certain period of time using Git Python?


Need to pull information about metadata changes from the project in the git (there is a local copy), namely: The number of commits per file (code, metadata) for 2 weeks on a certain branch on the folder na_gold'force-app/main/default'

import os
import time
import git
import datetime

Changedata = {}

MY_PATH = os.chdir(r'C:\Users\vsi\int\sfdevops_metrics\.project\na_gold')
repo = git.Repo(MY_PATH)
repo.git.checkout('Staging')

I can't figure out how to do it yet, because there's not a word in the documentation


Solution

  • This line give info

    file = repo.git.log('--since=2.weeks', '--name-only')
    

    All scrip have next lines

    import git
    import re
    import collections
    
    j = collections.defaultdict(int)
    Changedata = {}
    #MY_PATH = '/home/bot_slack_git/na_gold/'
    MY_PATH1 = r'C:\Users\vsi\int\sfdevops_metrics\.project\na_gold\force-app\main\default'
    MY_PATH = r'C:\Users\vsi\int\na_gold'
    repo = git.Repo(MY_PATH)
    file = repo.git.log('--since=2.weeks', '--name-only')