@@ -4,64 +4,67 @@ TMPDIR=$(mktemp -d -t "git-rebase-all")
4
4
log=" branchdata.log"
5
5
6
6
progress () {
7
- local w=120 p=$1 ; shift
8
- # create a string of spaces, then change them to dots
9
- printf -v dots " %*s" " $(( $p * $w / 100 )) " " " ; dots=${dots// / .} ;
10
- # print those dots on a fixed-width space plus the percentage etc.
11
- printf " \r\e[K|%-*s| %3d %% %s" " $w " " $dots " " $p " " $* " ;
7
+ local w=120 p=$1
8
+ shift
9
+ # create a string of spaces, then change them to dots
10
+ printf -v dots " %*s" " $(( p * w / 100 )) " " "
11
+ dots=${dots// / .}
12
+ # print those dots on a fixed-width space plus the percentage etc.
13
+ printf " \r\e[K|%-*s| %3d %% %s" " $w " " $dots " " $p " " $* "
12
14
}
13
15
14
-
15
16
on_fail () {
16
- local branch=" $1 "
17
- local branch_log=" $TMPDIR /branch-$branch .log"
18
- echo " Failed to rebase $branch " >> " $TMPDIR /$log "
19
- git rebase --abort >> " $branch_log " 2>&1
17
+ local branch=" $1 "
18
+ local branch_log=" $TMPDIR /branch-$branch .log"
19
+ echo " Failed to rebase $branch " >> " $TMPDIR /$log "
20
+ git rebase --abort >> " $branch_log " 2>&1
20
21
}
21
22
22
23
on_success () {
23
- local branch=" $1 "
24
- local branch_log=" $TMPDIR /branch-$branch .log"
25
- echo " Successfully rebased branch $branch " >> " $TMPDIR /$log "
26
- git push --force >> " $branch_log " 2>&1
24
+ local branch=" $1 "
25
+ local branch_log=" $TMPDIR /branch-$branch .log"
26
+ echo " Successfully rebased branch $branch " >> " $TMPDIR /$log "
27
+ git push --force >> " $branch_log " 2>&1
27
28
}
28
29
29
30
update_counter () {
30
- counter=" $(( $ counter+ ${1 :- 1} )) "
31
- progress $(( ( $ counter* 100 ) / ${branch_count:- $counter } ))
31
+ counter=" $(( counter + 1 )) "
32
+ progress $(( counter * 100 / ${branch_count:- $counter } ))
32
33
}
33
34
34
35
{
35
- branches=" $( git branch | sed " s/\*//g" | sed " s/ //g" ) "
36
- branch_count=" $( echo ${branches} | wc -w| tr -d ' \040\011\012\015' ) "
36
+ branches=" $( git branch | sed " s/\*//g" | sed " s/ //g" ) "
37
+ branch_count=" $( echo " ${branches} " | wc -w | tr -d ' \040\011\012\015' ) "
37
38
}
38
39
39
- git cleanbranches
40
+ git checkout master
41
+ git pull
40
42
41
- for branch in ${branches} ;
42
- do {
43
+ for branch in ${branches} ; do
44
+ {
43
45
branch_log=" $TMPDIR /branch-$branch .log"
44
- echo Processing branch ${branch} >> ${branch_log} 2>&1
45
- git checkout ${branch} >> ${branch_log} 2>&1
46
- if git rebase upstream/master >> ${branch_log} 2>&1
47
- then {
48
- on_success ${branch}
49
- }
50
- else {
51
- on_fail ${branch}
52
- }
46
+ echo Processing branch " ${branch} " >> " ${branch_log} " 2>&1
47
+ git checkout " ${branch} " >> " ${branch_log} " 2>&1
48
+ if git rebase origin/master >> " ${branch_log} " 2>&1 ; then
49
+ {
50
+ on_success " ${branch} "
51
+ }
52
+ else
53
+ {
54
+ on_fail " ${branch} "
55
+ }
53
56
fi
54
57
update_counter
55
- }
58
+ }
56
59
done
57
60
58
- git checkout master >> /dev/null 2>& 1
61
+ git checkout master >> /dev/null 2>&1
59
62
{
60
- echo
61
- echo " Printing log"
62
- cat " $TMPDIR /$log "
63
- echo
64
- echo " View rest of logs at $TMPDIR "
65
- ls -FGl $TMPDIR
63
+ echo
64
+ echo " Printing log"
65
+ cat " $TMPDIR /$log "
66
+ echo
67
+ echo " View rest of logs at $TMPDIR "
68
+ ls -FGl " $TMPDIR "
66
69
}
67
70
exit 0
0 commit comments