On Wed, Apr 01, 2026 at 05:58:13PM +0200, Agustin Martin wrote:
> El mar, 31 mar 2026 a las 16:57, Agustin Martin
> (<[email protected]>) escribió:
> >
> > On Tue, 31 Mar 2026 12:56:05 +0200 Agustin Martin <[email protected]> 
> > wrote:
> > > On Tue, Mar 31, 2026 at 04:04:04PM +0800, Chow Loong Jin wrote:
> > > > > > --- debian/watch --
> > > > > > Version: 5
> > > > > >
> > > > > > Template: Github
> > > > > > Owner: prusa3d
> > > > > > Project: prusaslicer
> > > > > > Release-Only: yes
> > > > > > ---
> > > > >
> > > > > Seems that attached patch helps with the 'Release-Only' problem in 
> > > > > rdma-core
> > > > > and nextcloud-desktop, using pure template watch files.
> > > > >
> > > > > It however does not help with slic3r-prusa because of the "version_" 
> > > > > prefix.
> > >
> > > I have seen that Yadd has opened a merge request to use a new
> > > 'Version-Prefix' option,
> > >
> > > https://salsa.debian.org/debian/devscripts/-/merge_requests/633
> 
> Hi all
> 
> I have looked at Yadd's code and I still think using 'Custom-Version'
> is way more versatile, so stands as my preferred choice. However, his
> code made me aware that my code was by far not the best
> implementation. I reimplemented it (only for Github, although the
> concept should be easy to extend to other uscan templates), see
> attached patch.

Hi,

Newer version of the patch with minor improvements in pod section for this
change.

-- 
Agustin
>From 0eb495ba8ca481efd685e965c724042bdb7e18e2 Mon Sep 17 00:00:00 2001
From: Agustin Martin Domingo <[email protected]>
Date: Wed, 1 Apr 2026 11:37:32 +0200
Subject: [PATCH] Github.pm: Allow customized version regexps with new
 'Custom-Version' parameter.

  Note: $custom_version is expected as in usual version regexps
  in matching pattern, so is not \Q\E quoted on purpose.

Closes: #1115546, #1120369
---
 lib/Devscripts/Uscan/Templates/Github.pm | 20 ++++++++++++++------
 scripts/uscan-templates.pod              | 11 +++++++++++
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/lib/Devscripts/Uscan/Templates/Github.pm b/lib/Devscripts/Uscan/Templates/Github.pm
index 30f1c07c..f306c074 100644
--- a/lib/Devscripts/Uscan/Templates/Github.pm
+++ b/lib/Devscripts/Uscan/Templates/Github.pm
@@ -5,10 +5,14 @@ use strict;
 sub transform {
     my $watchSource = shift;
     delete $watchSource->{template};
-    my $owner   = delete $watchSource->{owner};
-    my $project = delete $watchSource->{project};
-    my $dist    = delete $watchSource->{dist};
+    my $owner          = delete $watchSource->{owner};
+    my $project        = delete $watchSource->{project};
+    my $dist           = delete $watchSource->{dist};
+    my $custom_version = delete $watchSource->{customversion} || '';
+    my $version_regexp = $custom_version || $watchSource->{versiontype};
+
     die 'Missing Owner/Project or Dist' unless $dist or ($owner and $project);
+
     if ($dist) {
         $dist =~ s#^.*?github\.com#https://api.github.com/repos#;
         $dist =~ s/\.git$//;
@@ -22,14 +26,18 @@ sub transform {
       ||= 'https://api.github.com/repos/[^/]+/[^/]+/'
       . ($watchSource->{releaseonly} ? 'tarball/' : 'git/refs/tags/')
       . '(?>[^/]+(?<=(?:\D|alpha|beta|rc))\-)?'
-      . $watchSource->{versiontype}
+      . $version_regexp
       . '(?:(?=")|$)';
     $watchSource->{downloadurlmangle}
       ||= 's%(api.github.com/repos/[^/]+/[^/]+)/git/refs/%$1/tarball/refs/%g';
     $watchSource->{filenamemangle} ||= (
         $watchSource->{component}
-        ? 's%.*/(?:[^/]+(?<=(?:\D|alpha|beta|rc))\-)?@ANY_VERSION@%@PACKAGE@-@COMPONENT@-$1.tar.gz%'
-        : 's%.*/(?:[^/]+(?<=(?:\D|alpha|beta|rc))\-)?@ANY_VERSION@%@PACKAGE@-$1.tar.gz%'
+        ? 's%.*/(?:[^/]+(?<=(?:\D|alpha|beta|rc))\-)?'
+          . $version_regexp
+          . '%@PACKAGE@-@COMPONENT@-$1.tar.gz%'
+        : 's%.*/(?:[^/]+(?<=(?:\D|alpha|beta|rc))\-)?'
+          . $version_regexp
+          . '%@PACKAGE@-$1.tar.gz%'
     );
     $watchSource->{searchmode} ||= 'plain';
     $watchSource->{pgpmode}    ||= 'none';
diff --git a/scripts/uscan-templates.pod b/scripts/uscan-templates.pod
index 193a5800..c2ddd174 100644
--- a/scripts/uscan-templates.pod
+++ b/scripts/uscan-templates.pod
@@ -113,6 +113,17 @@ This template uses GitHub API to find archives to download.
 use B<ANY_VERSION> macro to find valid version. You can override this here
 using a valid macro name I<(ANY_VERSION or STABLE_VERSION or SEMANTIC_VERSION)>
 
+=item * B<Custom-Version> I<< (capturing version regexp) >>:
+Use a custom version regexp.
+Syntax is the same used for versions in B<Matching-Pattern>.
+Example:
+
+  Custom-Version: v(0\.7\.\d+)
+
+This parameter takes precedence over B<Version-Type> and can use its valid macro names, like in
+
+  Custom-Version: version_@ANY_VERSION@
+
 =back
 
 =head3 Example
-- 
2.53.0

Reply via email to