-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
|
||
clear | ||
|
||
# Get current branch name | ||
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) | ||
|
||
# Get the commit list | ||
commits=$(git log --oneline --pretty=format:"%H|%s|%an|%ae|%ad") | ||
|
||
# Initialize variables to track next commit | ||
next_commit_hash="" | ||
next_commit_message="" | ||
|
||
# Loop through the commits | ||
while IFS='|' read -r commit_hash commit_message author_name author_email author_date; do | ||
|
||
if [ "$commit_message" = "Archive update" ] && [ "$next_commit_message" = "Archive update" ]; then | ||
echo "Squashing $commit_hash into $next_commit_hash" | ||
|
||
# Checkout the parent of the asked commit | ||
git -c advice.detachedHead=false checkout "$commit_hash" | ||
git checkout HEAD~ | ||
|
||
# Merge the commit into it's parent, keeping the commit message of the parent | ||
git merge --squash "$commit_hash" | ||
git add . | ||
git add --update | ||
|
||
export GIT_COMMITTER_NAME="$author_name" | ||
export GIT_COMMITTER_EMAIL="$author_email" | ||
export GIT_COMMITTER_DATE="$author_date" | ||
git commit --amend --no-edit | ||
|
||
# Store the current commit | ||
newcommit=$(git rev-parse HEAD) | ||
|
||
# Rebase the starting branch onto the new commit | ||
echo "Checking out $BRANCH_NAME" | ||
git checkout "$BRANCH_NAME" | ||
echo "Rebasing" | ||
git rebase --committer-date-is-author-date -X theirs "$newcommit" | ||
|
||
break | ||
fi | ||
|
||
# Update nextious commit variables | ||
next_commit_hash=$commit_hash | ||
next_commit_message=$commit_message | ||
done <<< "$commits" | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
print(commit.author_name, commit.committer_name, commit.author_name.decode('utf-8') == 'GitHub Actions' and commit.author_name != commit.committer_name) | ||
|
||
if commit.author_name.decode('utf-8') == 'GitHub Actions' and commit.author_name != commit.committer_name: | ||
print(f'Commit {commit.id} has different author and committer: {commit.author_name} != {commit.committer_name}') | ||
commit.committer_name = commit.author_name | ||
commit.committer_email = commit.author_email | ||
commit.committer_date = commit.author_date | ||
|
||
|
||
# def handle(commit): | ||
# 'Reset the timezone of all commits.' | ||
# date_str = commit.author_date.decode('utf-8') | ||
# [seconds, timezone] = date_str.split() | ||
# new_date = f'{seconds} +0000' | ||
# commit.author_date = new_date.encode('utf-8') | ||
|
||
|
||
# handle(commit) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
git filter-repo --commit-callback "$(cat src/scripts/reset_committer.py)" | ||
git remote add origin "[email protected]:npanuhin/Bing-Wallpaper-Archive.git" | ||
git fetch origin | ||
git branch --set-upstream-to=origin/master master |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
clear | ||
set FILTER_BRANCH_SQUELCH_WARNING=1 | ||
git filter-branch -f --commit-filter ' | ||
if [[ $(git show -s --format=%an "$GIT_COMMIT") == "GitHub Actions" && $(git show -s --format=%ae "$GIT_COMMIT") == $(git show -s --format=%ce "$GIT_COMMIT") ]]; | ||
then | ||
echo "$(git show -s --format=%an "$GIT_COMMIT")"; | ||
GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; | ||
GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; | ||
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; | ||
fi | ||
git commit-tree "$@";' HEAD |