Skip to content

Scripts

Workflow for Forked Repo

Can set the upstream of main/master branch to genesis so everytime when you create a new branch, it's based on the remote main. This could avoid

git remote add genesis [email protected]/xxx/blabla
git branch --set-upstream-to genesis/main main
git pull & git checkout -b <your-branch>

Insert Panic before Exit

sed -i '' '/func Exit(code int) {/a\
\
    panic("os.Exit called")\
' $GOPLACE/src/os/proc.go

Amend Multiple Git Commits

Put the following content under file ~/batch_git_amend.py, then call to

git filter-repo -f --commit-callback "$(cat ~/batch_git_amend.py)"

from datetime import datetime
import random
import re

def handle(commit):
    # print all writable attributes inside the commit
    # if hasattr(commit, '__dict__'):
    #     print("\nWritable attributes using vars():")
    #     writable_attributes = vars(commit)
    #     for attr, value in writable_attributes.items():
    #         print(f"{attr}: {value}")

    # uncomment these fields to change the commit message
    # commit.author_name = b''
    # commit.author_email = b''
    # commit.committer_name = b''
    # commit.committer_email = b''
    # commit.committer_date= new_date.encode('utf-8')
    # commit.author_date = new_date.encode('utf-8')

handle(commit)