Last active
January 31, 2025 05:40
-
-
Save alanfzf/88ab81274223b5f0efeafd3ec08f5853 to your computer and use it in GitHub Desktop.
....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
start_date="2023-09-05" | |
end_date="2023-10-15" | |
commits=() | |
for commit in $(git log --format=%H | cut -d ' ' -f 1) | |
do | |
commits+=("$commit") | |
done | |
reversed_commits=() | |
for ((i=${#commits[@]}-1; i>=0; i--)) | |
do | |
reversed_commits+=("${commits[i]}") | |
done | |
# Convierte las fechas a formato epoch (número de segundos desde el 1 de enero de 1970) | |
start_epoch=$(date -d "$start_date" +%s) | |
end_epoch=$(date -d "$end_date" +%s) | |
# Calcula la diferencia en segundos entre las dos fechas | |
day=86400 # 86400 segundos en un día | |
diff=$((end_epoch - start_epoch)) | |
# Calcula la cantidad de intervalos que se deben dividir | |
intervals=61 | |
interval_length=$((diff / intervals)) | |
filter_commands="" | |
for ((i = 0; i < intervals; i++)); do | |
current_date_epoch=$((start_epoch + i * interval_length)) | |
current_date=$(date -d "@$current_date_epoch" "+%Y-%m-%dT%H:%M:%S") | |
commit=${reversed_commits[i]} | |
echo "$commit $current_date" | |
filter_commands+='if [ $GIT_COMMIT = '$commit' ]; then | |
export GIT_AUTHOR_DATE="'$current_date'" | |
export GIT_COMMITTER_DATE="'$current_date'" | |
fi; ' | |
done | |
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --env-filter "$filter_commands" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment