Fix test of scripts dir existence
[khome.git] / home / bin / git-edit-email
CommitLineData
2b274490
SK
1#!/bin/sh
2
3# =============================================================================
4# This is a modified version of this:
5# https://help.github.com/articles/changing-author-info
6# =============================================================================
7
8
9FILTER_SCRIPT_TEMPLATE='
10an="$GIT_AUTHOR_NAME";
11am="$GIT_AUTHOR_EMAIL";
12cn="$GIT_COMMITTER_NAME";
13cm="$GIT_COMMITTER_EMAIL";
14
15if [ "$GIT_COMMITTER_EMAIL" = "OLD_COMMITTER_EMAIL" ];
16then
17 cn="$GIT_COMMITTER_NAME";
18 cm="NEW_COMMITTER_EMAIL";
19fi;
20
21if [ "$GIT_AUTHOR_EMAIL" = "OLD_AUTHOR_EMAIL" ];
22then
23 an="$GIT_AUTHOR_NAME";
24 am="NEW_AUTHOR_EMAIL";
25fi;
26
27export GIT_AUTHOR_NAME="$an";
28export GIT_AUTHOR_EMAIL="$am";
29export GIT_COMMITTER_NAME="$cn";
30export GIT_COMMITTER_EMAIL="$cm";
31'
32
33
34git_filter_branch() {
35 git filter-branch -f --env-filter "$1"
36}
37
38
39main() {
40 old_email="$1"
41 new_email="$2"
42
43 filter_script=$(\
44 echo $FILTER_SCRIPT_TEMPLATE \
45 | sed "s/OLD_COMMITTER_EMAIL/$old_email/g" \
46 | sed "s/NEW_COMMITTER_EMAIL/$new_email/g" \
47 | sed "s/OLD_AUTHOR_EMAIL/$old_email/g" \
48 | sed "s/NEW_AUTHOR_EMAIL/$new_email/g" \
49 )
50
51 git_filter_branch "$filter_script"
52}
53
54main "$@"
This page took 0.091912 seconds and 4 git commands to generate.