I pulled git logs using the command git log --all --numstat --pretty=format:'--%h--%ad--%aN--%s' > ../react_git.logs
. I want to have a column for merge commit as well so I can analyze which author has merged commit the most and so on. I code in this way to create a dataframe out of the generate logs
COMMIT_LOG = os.path.join(os.path.abspath(''), 'react_git.logs')
raw_df = pd.read_csv(COMMIT_LOG, sep="\u0012", header=None, names=["raw"])
commit_marker = raw_df[raw_df["raw"].str.startswith("--", na=False)]
commit_info = commit_marker['raw'].str.extract(r"^--(?P<sha>.*?)--(?P<timestamp>.*?)--(?P<author>.*?)--(?P<message>.*?)$", expand=True)
commit_info.insert(loc=2, column='date', value=pd.to_datetime(commit_info['timestamp'], utc=True))
commit_info_copy = commit_info.loc[:]
commit_info_copy['today'] = pd.to_datetime('today', utc=True)
commit_info['age'] = commit_info_copy['date'] - commit_info_copy['today']
file_stats_marker = raw_df[~raw_df.index.isin(commit_info.index)]
file_stats = file_stats_marker['raw'].str.split("\t", expand=True)
file_stats = file_stats.rename(columns={0: "insertion", 1: "deletion", 2: "filepath"})
file_stats['insertion'] = pd.to_numeric(file_stats['insertion'], errors="coerce")
file_stats['deletion'] = pd.to_numeric(file_stats['deletion'], errors="coerce")
file_stats['churn'] = file_stats['insertion'] - file_stats['deletion']
commit_data = commit_info.reindex(raw_df.index).fillna(method="ffill")
commit_data = commit_data[~commit_data.index.isin(commit_info.index)]
df = commit_data.join(file_stats)
print(df.size)
print(df.head())
If I have such logs
--cae635054--Sat Jun 26 14:51:23 2021 -0400--Andrew Clark--`act`: Resolve to return value of scope function (#21759)
31 0 packages/react-reconciler/src/__tests__/ReactIsomorphicAct-test.js
1 1 packages/react-test-renderer/src/ReactTestRenderer.js
24 14 packages/react/src/ReactAct.js
--e2453e200--Fri Jun 25 15:39:46 2021 -0400--Andrew Clark--act: Add test for bypassing queueMicrotask (#21743)
50 0 packages/react-reconciler/src/__tests__/ReactIsomorphicAct-test.js
--8f03109cd--Wed Sep 11 09:51:32 2019 -0700--Brian Vaughn--Moved backend injection to the content script (#16752)
--efa780d0a--Wed Sep 11 09:51:24 2019 -0700--Brian Vaughn--Removed DT inject() script since it's no longer being used
0 24 packages/react-devtools-extensions/src/inject.js
--4290967d4--Wed Sep 11 09:34:31 2019 -0700--Brian Vaughn--Merge branch 'tt-compat' of https://github.com/onionymous/react into onionymous-tt-compat
--f09854a9e--Wed Sep 11 09:30:57 2019 -0700--Brian Vaughn--Moved inline comment.
3 5 packages/react-devtools-extensions/src/injectGlobalHook.js
then 8f03109cd
and 4290967d4
won't be in a dataframe which is very important for the analysis to find number of merge commit and like I said above.
How can I put those data in a dataframe with insertion: 0, deletion: 0 and filepath: 0 and a column or any way to differentiate them with other so it will be easier to know it's related to merge commit?
I have this on repl as well with logs file https://replit.com/@milanregmi/metricsLogs#main.py