Skip to content

Instantly share code, notes, and snippets.

@cristea2017
Last active April 1, 2024 13:42
Show Gist options
  • Save cristea2017/63af3ce451c2313dfde9ba4dbbb1c08b to your computer and use it in GitHub Desktop.
Save cristea2017/63af3ce451c2313dfde9ba4dbbb1c08b to your computer and use it in GitHub Desktop.
git

git log --since="2024-01-01" --until="2024-01-31" --pretty=format:"%s"

git log --since="2024-02-01" --until="2024-02-29" --pretty=format:"%s"

git log --since="2024-03-01" --until="2024-03-31" --pretty=format:"%s"

git log --since="2024-04-01" --until="2024-04-30" --pretty=format:"%s"

git log --since="2024-05-01" --until="2024-05-31" --pretty=format:"%s"

git log --since="2024-06-01" --until="2024-06-30" --pretty=format:"%s"

git log --since="2024-07-01" --until="2024-07-31" --pretty=format:"%s"

git log --since="2024-08-01" --until="2024-08-31" --pretty=format:"%s"

git log --since="2024-09-01" --until="2024-09-30" --pretty=format:"%s"

git log --since="2024-10-01" --until="2024-10-31" --pretty=format:"%s"

git log --since="2024-11-01" --until="2024-11-30" --pretty=format:"%s"

git log --since="2024-12-01" --until="2024-12-31" --pretty=format:"%s"

#!/bin/bash

# Variables
LOG_FILE="/Users/cristea/Desktop/report.txt"
REPO_DIRECTORY="/Users/cristea/Desktop/straus.mobile"  # Change this to the Git repository path
WEBHOOK_URL=""  # Replace with your actual webhook URL

# Delete file if exists
rm "$LOG_FILE"

# Change to the Git repository directory
cd "$REPO_DIRECTORY"

# Set the start date for the last month (e.g., September)
set `date +%m" "%Y`
CURMTH=$1
CURYR=$2
if [ $CURMTH -eq 1 ]
then PRVMTH=12
     PRVYR=`expr $CURYR - 1`
else PRVMTH=`expr $CURMTH - 1`
     PRVYR=$CURYR
fi
if [ $PRVMTH -lt 10 ]
then PRVMTH="0"$PRVMTH
fi
LASTDY=`cal $PRVMTH $PRVYR | egrep "28|29|30|31" |tail -1 |awk '{print $NF}'`

START_DATE=$PRVYR-$PRVMTH-01
END_DATE=$PRVYR-$PRVMTH-$LASTDY
echo First Day: $START_DATE
echo Last Day: $END_DATE

# Loop through the commits and log them
git log --since="$START_DATE" --until="$END_DATE" --pretty=format:"%s" >> "$LOG_FILE"

# Send the log to the webhook
FILE_CONTENT=$(cat "$LOG_FILE")
echo $FILE_CONTENT

payload1='{"channel": "#reports", "username": "webhookbot", "text": "'"$FILE_CONTENT"'", "icon_emoji": ":ghost:"}'
curl -X POST --data-urlencode "payload=$payload1" "$WEBHOOK_URL"

# Optionally, you can delete the log file after sending
rm "$LOG_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment