Skip to content

Commit e8416b0

Browse files
committed
Add git-last-processed-tags.sh
This is used for backups of the git tags which FreshPorts adds to the repos so it knows where it left off when last processing commits.
1 parent c4924e9 commit e8416b0

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

git-last-processed-tags.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/sh
2+
3+
# Dump the latest processed commits.
4+
# based upon git-delta.sh
5+
# They should be kept in sync.
6+
#
7+
8+
if [ ! -f /usr/local/etc/freshports/config.sh ]
9+
then
10+
echo "/usr/local/etc/freshports/config.sh.sh not found by $0"
11+
exit 1
12+
fi
13+
14+
. /usr/local/etc/freshports/config.sh
15+
16+
# this can be a space separated list of repositories to check
17+
# e.g. "doc ports src"
18+
repos="${REPOS_TO_CHECK_GIT}"
19+
20+
LOGGERTAG='git-delta.sh'
21+
22+
# what remote are we using on this repo?
23+
REMOTE='origin'
24+
25+
# where we do dump the XML files which we create?
26+
XML="${INGRESS_MSGDIR}/incoming"
27+
28+
result=0
29+
30+
for repo in ${repos}
31+
do
32+
# convert the repo label to a physical directory on disk
33+
dir=$(convert_repo_label_to_directory ${repo})
34+
35+
# empty means error
36+
if [ "${dir}" == "" ]; then
37+
logfile "FATAL error, repo='${repo}' is unknown: cannot translate it to a directory name"
38+
continue
39+
fi
40+
41+
# where is the repo directory?
42+
# This is the directory which contains the repos.
43+
REPODIR="${INGRESS_PORTS_DIR_BASE}/${dir}"
44+
45+
if [ -d ${REPODIR} ]; then
46+
else
47+
logfile "FATAL error, REPODIR='${REPODIR}' is not a directory"
48+
continue
49+
fi
50+
51+
# on with the work
52+
53+
cd ${REPODIR}
54+
55+
NAME_OF_HEAD="main"
56+
NAME_OF_REMOTE=$REMOTE
57+
MAIN_BRANCH="$NAME_OF_REMOTE/$NAME_OF_HEAD"
58+
59+
${GIT} for-each-ref --format '%(objecttype) %(refname)' \
60+
| sed -n 's/^commit refs\/remotes\///p' \
61+
| while read -r refname
62+
do
63+
case $refname in
64+
origin/main)
65+
;;
66+
67+
origin/2[01][0-9][0-9]Q[1-4])
68+
;;
69+
70+
*)
71+
continue
72+
;;
73+
esac
74+
75+
ref=$(${GIT} rev-parse freshports/$refname^{})
76+
echo "$repo:freshports/$refname:$ref"
77+
78+
done
79+
done
80+
logger things
81+
82+
exit $result

0 commit comments

Comments
 (0)