forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup-tags
executable file
·41 lines (36 loc) · 1.39 KB
/
cleanup-tags
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
#!/bin/sh -e
function cleanup_git_tag ()
{
local tag="$1"
local d=$(echo "$tag" | sed 's|.*_X||;s|/.*||;s|.*_2|2|')
local DEL_TAG=$(python -c "import os;from time import time;from datetime import datetime;print int(datetime.strptime('$d', '%Y-%m-%d-%H%M').strftime('%s'))<(time()-(${DAYS_TO_KEEP}*86400))")
if [ "${DEL_TAG}" = "True" ] ; then
$ECHO git push origin :$tag
else
echo "Keeping tag $tag"
fi
}
#Keep only last 21 days/3 weeks of IB tags
DAYS_TO_KEEP=21
ECHO=
if [ "X$DRY_RUN" = "Xtrue" ]; then ECHO=echo; fi
rm -rf cmssw cmsdist cmssw-tags cmsdist-tags
echo "Working on cmssw tags"
git init cmssw
pushd cmssw
git remote add origin [email protected]:cms-sw/cmssw
git ls-remote --tags origin | grep refs/tags | sed -e 's|.*refs/tags/||' | grep '^CMSSW_' | grep '_X_' | grep '_2[0-9][0-9][0-9]-[0-1][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]' | sort > ../cmssw-tags
for tag in $(grep '^CMSSW_' ../cmssw-tags) ; do
cleanup_git_tag $tag
done
echo "Done cmssw tags"
popd
echo "Working on cmsdist tags"
git init cmsdist
pushd cmsdist
git remote add origin [email protected]:cms-sw/cmsdist
git ls-remote --tags origin | grep refs/tags | sed -e 's|.*refs/tags/||' | grep '/CMSSW_' | grep '_X_' | grep '_2[0-9][0-9][0-9]-[0-1][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]' | sort > ../cmsdist-tags
for tag in $(grep '^\(IB\|ALL\|ERR\)/' ../cmsdist-tags) ; do
cleanup_git_tag $tag
done
echo "Done cmsdist tags"