-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcz.sh
More file actions
executable file
·179 lines (154 loc) · 5.1 KB
/
Copy pathcz.sh
File metadata and controls
executable file
·179 lines (154 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
# collect all relevant directories. Currently - by hand
uptodate="xxxxxxx"
fetch_origin=true
fetch_upstream=true
function clear_dirname()
{
#if [ $(hostname) == "rflap2" ]; then
echo $1 | sed 's=/home/rfriedma/=-- -- =' | sed 's=src/= =' | sed 's=/ceph= -- -- -- =' | awk -e '{printf "%s",substr($0,1,18);}'
#else
# echo $1 | sed 's=/home/ronen-fr/=-- -- =' | sed 's=src/= =' | sed 's=/ceph= -- -- -- =' | awk -e '{printf "%s",substr($0,1,18);}'
#fi
}
function short_st()
{
me=`git branch --show-current`
up=`git show-branch origin/$me` || uptodate="local-only"
cst=`git status -uno --ignore-submodules=all`
echo $cst | grep -q 'up to date' && uptodate="up-to-date"
echo $cst | grep -q 'ahead' && uptodate="ahead "
echo $cst | grep -q 'behind' && uptodate="behind "
echo $cst | grep -q 'detached' && uptodate="detached "
echo $cst | grep -q 'diverged' && uptodate="diverged "
}
function refs_diff()
{
if git ls-remote --get-url origin | grep -q ronen && git ls-remote --get-url upstream | grep -q ceph; then
if $fetch_upstream; then
git fetch upstream main > /dev/null 2>&1
fi
df_m_om=`git rev-list --count main..origin/main | sed 's/ //'`
#df_om_m=`git rev-list --count origin/main..main | sed 's/ //'`
#df_um_om=`git rev-list --count upstream/main..origin/main | sed 's/ //'`
df_om_um=`git rev-list --count origin/main..upstream/main`
echo -n "[./o: $df_m_om o-ms/u-ms:$df_om_um] " | awk -e '{printf "%s",substr($0,1,26);}'
else
echo -n "{{xx-rt-xx}} " | awk -e '{printf "%s",substr($0,1,30);}'
fi
}
function modified_files()
{
if git ls-remote --get-url origin | grep -q ronen ; then
n_modified=`git status --ignore-submodules --porcelain | grep -e '^ [MDR]' | wc -l`
n_added=`git status --ignore-submodules --porcelain | grep -e '^ A' | wc -l`
echo -n "<M:$n_modified - A:$n_added> " | awk -e '{printf "%s",substr($0,1,16);}'
else
echo -n "<.....> " | awk -e '{printf "%s",substr($0,1,16);}'
fi
}
function old_branches()
{
git log --date=relative --pretty=oneline -g | awk -f <(cat - <<'EOD'
BEGIN { br_count = 0; }
/moving from main/ {next;}
/moving from/ {
#print $0
br=$8
if (seen[$8]) {
next;
}
seen[$8] = $NF
if (br_count>8) {
exit 0;
}
br_count=br_count+1
date_from = substr($0,match($0,"{.*}"),RLENGTH);
old_branch=$8
# search the next line for the latest commit for the moved-from
getline
# note that this is only a partial solution. the next line is not
# guaranteed to hold the information
printf "-\t%8.8s %-15.15s %s\n",substr($1,1,8),date_from,old_branch;
}
EOD
)
}
function build_dir_info()
{
if [ -e build ]; then
ls -ld build | awk '{ printf "\n\t%s-%s %s %s",$7,$6,$8,$9; }'
if [ -e build/compile_commands.json ]; then
# clang / gcc ? crimson?
comp="G++"
grep -i -q clang build/compile_commands.json && comp="Clang"
crimson="Classic"
grep -i -q SEASTAR build/compile_commands.json && crimson="Crimson"
echo -e -n " $comp $crimson \t"
else
echo -n " [[no script]] "
fi
if [ -e build/build.ninja ]; then
ls -ld build/build.ninja | awk '{ print " { Ninja: " $7 "-" $6 " " $8 " " $9 " }" }'
else
echo
fi
else
echo -e "\n\t-- no build"
fi
}
function oneceph()
{
d=$1
echo
#echo '---------------------'
#echo $fetch_origin
cd $d
if $fetch_origin; then
git fetch > /dev/null 2>&1
fi
#git --no-pager log -1 --format="%h %s"
comt=`git --no-pager log -1 --format="%h %s"`
branch=`git rev-parse --abbrev-ref HEAD`
dirt="$(clear_dirname $d)"
short_st
echo "$dirt -- -- $uptodate -- $branch $(refs_diff)"
echo " $comt $(modified_files)"
# make sure we have a "normal" origin/upstream setting
git ls-remote --get-url origin | grep -q ronen || echo " ******* irregular origin ***********"
build_dir_info
#if [ -e build ]; then
# ls -ld build | awk '{ printf "\n\t%s-%s %s %s",$7,$6,$8,$9; }'
# if [ -e build/build.ninja ]; then
# ls -ld build/build.ninja | awk '{ print " Ninja: " $7 "-" $6 " " $8 " " $9 }'
# fi
#fi
echo
#git log --date=relative --pretty=oneline -g | grep 'moving from' | cut -n -b1-8,46- | cut -d\ -f1,2,3,7 | grep -v main | sed -e 's/^/ /;4q'
old_branches
}
if [ $(hostname) == "rflap" ]; then
ac1="fx7 master rf_sc fix_4 cln_may scrub0 scrub1 s2 scr5 scr6"
for u in $ac1; do
ac="$ac $HOME/src/$u/ceph"
done
elif [ $(hostname) == "rflap2" ]; then
ac1="m1 m2 m3 m4 m5 m6 down"
for u in $ac1; do
ac="$ac $HOME/src/$u/ceph"
done
else
#ac="/home/ronen-fr/tmp2/rt1/ceph /home/ronen-fr/tmp2/rt2/ceph /home/ronen-fr/tmp2/rt3/ceph /home/ronen-fr/tmp2/rt4/ceph /home/ronen-fr/tmp2/bg5/ceph /home/ronen-fr/tmp2/pa1/ceph"
ac=""
ac1="k1 k2 k3 k4 k5 k6 k7 k8 k9 "
for u in $ac1; do
if [ -e "$HOME/src/$u/ceph" ]; then
ac="$ac $HOME/src/$u/ceph"
fi
done
fi
[ $# -gt 0 ] && fetch_upstream=false
[ $# -gt 1 ] && fetch_origin=false
for d in $ac; do
oneceph $d
done