commit: ba3b218c60f60a72ca4c843287df97fdf1bfdc44
parent 34b87ee5487883414c4c6d18c7120b931a66c62d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 19 Jul 2025 08:17:45 +0200
git-hooks/post-update.srht: check if HEAD got updated before running
Diffstat:
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/git-hooks/post-update.srht b/git-hooks/post-update.srht
@@ -68,19 +68,33 @@ EOF
 }
 
 if (not(defined($ENV{'SRHT_HOST'}) && defined($ENV{'SRHT_TOKEN'}))) {
-	print 'Environment variables $SRHT_HOST and $SRHT_TOKEN are undefined';
+	print 'Environment variables $SRHT_HOST and $SRHT_TOKEN are undefined', "\n";
 	exit 1;
 }
 
-if (-d "${workdir}/.builds") {
+if ($#ARGV < 0) {
+	print "No refs passed, skipping\n";
+	exit 0;
+}
 
-	# TODO: Shuffle manifests, take 4
-	my @manifests = <"${workdir}/.builds/*.yml">;
-	for (@manifests) {
-		new_job $_;
+open(my $f, '<', 'HEAD') or die "Failed to read HEAD: $!\n";
+chomp(my $head = <$f>);
+close($f);
+
+for(@ARGV) {
+	next if("ref: $_" ne $head);
+
+	if (-d "${workdir}/.builds") {
+		# TODO: Shuffle manifests, take 4
+		my @manifests = <"${workdir}/.builds/*.yml">;
+		for (@manifests) {
+			new_job $_;
+		}
+	} elsif (-e "${workdir}/.build.yml") {
+		new_job "${workdir}/.build.yml";
+	} else {
+		print "No build manifest found\n";
 	}
-} elsif (-e "${workdir}/.build.yml") {
-	new_job "${workdir}/.build.yml";
-} else {
-	print "No build manifest found";
+
+	exit 0;
 }