livecheck: add git support

This commit is contained in:
Mohamed Akram
2025-03-06 17:34:14 +04:00
committed by Joshua Root
parent fb16351d6a
commit c1c02d8b4c
2 changed files with 27 additions and 3 deletions
+8 -1
View File
@@ -2195,6 +2195,8 @@ tag of the freecode XML file),
(retrieve the version by applying a regex to some URL resource),
.Em regexm
(retrieve the version by applying a multi-line regex to some URL resource),
.Em git
(retrieve the commit from a remote git branch),
.Em md5
(compares the md5 sum of some URL resource) or
.Em none
@@ -2213,7 +2215,7 @@ is one of these, else
.Em freecode
.br
.Sy Values:
.Em freecode sourceforge googlecode moddate regex regexm md5 none
.Em freecode sourceforge googlecode moddate regex regexm git md5 none
.It Ic livecheck.name
Name of the project for live checks (used for freecode, sourceforge, and googlecode checks).
.br
@@ -2269,6 +2271,11 @@ Be sure to use a regular expression grouping around the version component.
.br
.Sy Type:
.Em optional
.It Ic livecheck.branch
git branch to use for getting latest commit.
.br
.Sy Type:
.Em optional
.It Ic livecheck.md5
md5 sum to use for md5 comparison.
.br
+19 -2
View File
@@ -45,13 +45,14 @@ namespace eval portlivecheck {
}
# define options
options livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version livecheck.ignore_sslcert livecheck.compression livecheck.curloptions
options livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.branch livecheck.name livecheck.distname livecheck.version livecheck.ignore_sslcert livecheck.compression livecheck.curloptions
# defaults
default livecheck.url {$homepage}
default livecheck.type default
default livecheck.md5 {}
default livecheck.regex {}
default livecheck.branch {}
default livecheck.name default
default livecheck.distname default
default livecheck.version {$version}
@@ -60,10 +61,11 @@ default livecheck.compression yes
default livecheck.curloptions [list --append-http-header "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"]
proc portlivecheck::livecheck_main {args} {
global livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version \
global livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.branch livecheck.name livecheck.distname livecheck.version \
livecheck.ignore_sslcert \
livecheck.compression \
livecheck.curloptions \
git.cmd \
homepage portpath \
master_sites name subport
@@ -234,6 +236,21 @@ proc portlivecheck::livecheck_main {args} {
}
}
}
"git" {
if {${livecheck.branch} eq {}} {
set livecheck.branch "HEAD"
}
ui_debug "Getting latest commit from ${livecheck.url} ${livecheck.branch}"
if {[catch {exec ${git.cmd} ls-remote ${livecheck.url} ${livecheck.branch}} result]} {
ui_error "cannot check if $subport was updated ($result)"
set updated -1
} else {
set updated_version [lindex [split $result] 0]
if {$updated_version ne ${livecheck.version}} {
set updated 1
}
}
}
"none" {
}
default {