forked from cms-sw/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup-tags
executable file
·59 lines (54 loc) · 1.98 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/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 14 days/2 weeks of IB tags
DAYS_TO_KEEP=14
ECHO=
if [ "X$DRY_RUN" = "Xtrue" ]; then ECHO=echo; fi
repo="cmssw"
echo "Working on ${repo} tags"
rm -rf ${repo} ${repo}-tags
git init ${repo}
pushd ${repo}
git remote add origin [email protected]:cms-sw/${repo}
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 > ../${repo}-tags
for tag in $(grep '^CMSSW_' ../${repo}-tags) ; do
cleanup_git_tag $tag
done
echo "Done ${repo} tags"
popd
rm -rf ${repo} ${repo}-tags
repo="cmssw-cfipython"
echo "Working on ${repo} tags"
rm -rf ${repo} ${repo}-tags
git init ${repo}
pushd ${repo}
git remote add origin [email protected]:cms-sw/${repo}
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 > ../${repo}-tags
for tag in $(grep '^CMSSW_' ../${repo}-tags) ; do
cleanup_git_tag $tag
done
echo "Done ${repo} tags"
popd
rm -rf ${repo} ${repo}-tags
repo="cmsdist"
echo "Working on ${repo} tags"
rm -rf ${repo} ${repo}-tags
git init ${repo}
pushd ${repo}
git remote add origin [email protected]:cms-sw/${repo}
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 > ../${repo}-tags
for tag in $(grep '^\(IB\|ALL\|ERR\)/' ../${repo}-tags) ; do
cleanup_git_tag $tag
done
echo "Done ${repo} tags"
rm -rf ${repo} ${repo}-tags