Skip to content

Instantly share code, notes, and snippets.

Avatar
😊

Tomasz Prasołek tomaszprasolek

😊
View GitHub Profile
View git-addhashtotasknumber
#!/bin/bash
currentBranchName=$(git rev-parse --abbrev-ref HEAD)
desinationBranch=develop
add_hash() {
echo ""
git filter-repo -f --refs $desinationBranch..$currentBranchName --message-callback '
lastWord = message.split()[-1]
@tomaszprasolek
tomaszprasolek / prepare-commit-msg
Created Jul 9, 2020
V2 version - withoun # before task number
View prepare-commit-msg
#!/bin/sh
BRANCH_NAME=$(git symbolic-ref --short HEAD)
STORY_NUMBER=$(echo $BRANCH_NAME | sed -n 's/.*-\([0-9]\)/\1/p') # Get story number from branch name - "my_feature_branch-123"
COMMIT_MSG=`cat $1`
if [ x != x${STORY_NUMBER} ]; then # Checf if STORY_NUMBER is NOT empty
if [ x = x${2} ]; then # Check if commit message is empty
sed -i.back "1s/^/$STORY_NUMBER/" "$1"
@tomaszprasolek
tomaszprasolek / post-commit
Created Apr 2, 2020
Play sound after commit
View post-commit
#!/bin/sh
toplevel_path=`git rev-parse --show-toplevel`
powershell -c "(New-Object System.Media.SoundPlayer '$toplevel_path\.git\hooks\applause10.wav').PlaySync()" > /dev/null 2>&1 &
@tomaszprasolek
tomaszprasolek / git-azuredevops-v2
Last active Mar 8, 2020
Script add # symbol to Azure DevOps task number in the end of commit messages in working branch
View git-azuredevops-v2
#!/bin/bash
currentBranchName=$(git rev-parse --abbrev-ref HEAD)
add_hash() {
echo ""
git filter-repo -f --refs develop..$currentBranchName --message-callback '
lastWord = message.split()[-1]
def RepresentsInt(s):
@tomaszprasolek
tomaszprasolek / git-azuredevops
Last active Feb 29, 2020
Script add # symbol to Azure DevOps task number in the end of commit messages to last X commits (X passed by parameter)
View git-azuredevops
#!/bin/bash
USAGE="USAGE: git azuredevops NUMBER_OF_COMMITS\nExample: git azuredevops 5"
show_usage () {
echo -e "\n$USAGE"
}
add_hash() {
echo ""
@tomaszprasolek
tomaszprasolek / git-feature
Last active Mar 27, 2019
Script create local branch and after that set upstream branch
View git-feature
#!/bin/bash
if [ x = x${1} ]; then
echo ">>> Enter branch name"
exit 1
fi
if [[ $1 == feature* ]]
then
BRANCH_NAME=$1
@tomaszprasolek
tomaszprasolek / createEmptyCommits.sh
Created Jan 9, 2019
Create 5 empty commits with passed message. For test purposes only.
View createEmptyCommits.sh
#!/bin/bash
for i in {1..5}
do
git commit -m "$1 $i" --allow-empty
done
@tomaszprasolek
tomaszprasolek / Change commiter and author date
Last active May 31, 2019
Change commiter and author date
View Change commiter and author date
git filter-branch --env-filter \
'if [ $GIT_COMMIT = 50421880a94e18f9344b43574eecbbab8e941c89 ]
then
export GIT_AUTHOR_DATE="Fri Nov 2 12:00:00 2018 +0000"
export GIT_COMMITTER_DATE="Fri Nov 2 12:00:00 2018 +0000"
fi'
View git reflog live script
while :; do
output=$(git reflog)
clear
echo "$output"
sleep 1
done
@tomaszprasolek
tomaszprasolek / git_script.ahk
Last active Jul 16, 2020
My Git AutoHotKey script.
View git_script.ahk
#SingleInstance force
#IfWinActive ahk_class VirtualConsoleClass
::grc::git rebase --continue
::gmt::git mergetool
::gpf::git push --force-with-lease
::gch::git checkout
::gri::git rebase -i HEAD~
::gc::git commit
::gca::git commit --amend
::gcan::git commit --amend --no-edit