Skip to content

Commit

Permalink
add code
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Sep 11, 2024
1 parent 74f2d30 commit 913b388
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
linux
bpf
mails/bpf
linux/commits.csv
7 changes: 2 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
linux:
git clone https://github.com/torvalds/linux

bpf:
git clone --mirror http://lore.kernel.org/bpf/0 bpf/git/0.git
cd bpf/git/0.git && ../../../dump.sh
mails/bpf:
cd mails && git clone --mirror http://lore.kernel.org/bpf/0 bpf/git/0.git

linux/commits.csv:
cd linux && git log --pretty=format:'"%H","%an","%ae","%ad","%cn","%ce","%cd","%T","%P","%B"' --date=iso > commits.csv
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# test-git
# bpf subsystem

```
git clone --mirror http://lore.kernel.org/bpf/0 bpf/git/0.git
- Wed, 13 Feb 2019 Until 10 Sep 2024: 126469 mails

cd bpf/git/0.git
../../../dump.sh
```

Feature versions:

Expand Down
36 changes: 36 additions & 0 deletions analysis/parse_commit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import csv

def process_commits_csv(file_path):
# Open the CSV file for reading
with open(file_path, mode='r', encoding='utf-8') as file:
# Use csv.reader to parse the CSV file
csv_reader = csv.reader(file)

# Define headers for better understanding of what each column represents
headers = ["commit_hash", "author_name", "author_email", "author_date",
"committer_name", "committer_email", "committer_date",
"tree_hash", "parent_hashes", "full_commit_message"]

# Initialize an empty list to store processed commits
commits = []

# Process each row in the CSV
for row in csv_reader:
# Ensure that the row is correctly formatted
if len(row) == len(headers):
commit_data = dict(zip(headers, row))
commits.append(commit_data)

return commits

if __name__ == "__main__":
# Path to your CSV file
file_path = 'commits.csv'

# Process the CSV file
commits = process_commits_csv(file_path)

# Print out a summary of the commits
# print_commit_summary(commits)

# You can further process `commits` list as needed (e.g., filter by author, date, etc.)
1 change: 1 addition & 0 deletions data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# The data will be generated here.
2 changes: 2 additions & 0 deletions scripts/count_mails.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The first mail is Wed, 13 Feb 2019 16:56:04 -0500
git rev-list --all --objects | grep 'm$' | awk '{print $1}' | wc -l
15 changes: 15 additions & 0 deletions scripts/dump_commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Check if the number of commits (n) is passed as an argument
if [ -z "$1" ]; then
echo "Usage: $0 <number_of_commits>"
exit 1
fi

# Store the argument in a variable
n=$1

# Run git log with the specified number of commits and format the output into a CSV file
git log --pretty=format:'"%H","%an","%ae","%ad","%cn","%ce","%cd","%T","%P","%B","%N"' -n "$n" --date=iso > commits.csv

echo "Dumped $n commits to commits.csv"
File renamed without changes.
1 change: 1 addition & 0 deletions scripts/mention_bpf_commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git log --grep=bpf --oneline | wc -l

0 comments on commit 913b388

Please sign in to comment.