Skip to content

Instantly share code, notes, and snippets.

@chrsp
Last active January 12, 2024 15:20
Show Gist options
  • Save chrsp/218b37cc2f59ebe6c58ddd6ed507e367 to your computer and use it in GitHub Desktop.
Save chrsp/218b37cc2f59ebe6c58ddd6ed507e367 to your computer and use it in GitHub Desktop.
Returns all the files updated by the provided authors in the interval of a month
#!/bin/bash
#This Bash script generates a succinct summary of file changes in Git repositories for specified users over the last month. The script accepts a list of Git usernames, producing a Markdown file (`changed_files.md`) that lists unique changed files for each user, limited to commits made within the past month. To ensure a fresh summary is created with each execution, the script clears the previous content of the output file.
#1. Edit the `git_users` array with the desired Git usernames and emails.
#2. Save the script and make it executable.
#3. Run the script to obtain an updated changes summary in the Markdown file.
# List of git users
git_users=(
"user1"
"user2"
"user3"
)
# Output file
output_file="changed_files.md"
# Function to get unique file names
get_unique_files() {
awk '!seen[$0]++'
}
# Clear the previous content of the output file
> "$output_file"
# Loop through git users
for user in "${git_users[@]}"; do
# Get the list of changed files for the user in the last month
changed_files=$(git log --author="$user" --pretty=format: --name-only --since="1 month ago" | grep -v '^$')
# Append to output file
echo "### Changes by $user in the last month" >> "$output_file"
echo "$changed_files" | get_unique_files >> "$output_file"
echo "" >> "$output_file"
done
echo "Done! Check $output_file for the results."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment