summaryrefslogtreecommitdiff
path: root/pkg/config/lib/hg/hg.star
diff options
context:
space:
mode:
authorNicolas Paul <n@nc0.fr>2023-06-01 12:03:08 +0200
committerNicolas Paul <n@nc0.fr>2023-06-01 12:03:08 +0200
commit8658aa415b3a4b8dd24a6d9ee731b96d60e98885 (patch)
tree85274c236d44f6e79c140e69539251c580ae11f1 /pkg/config/lib/hg/hg.star
parent9d0ba6d46d7101199bf65b00145e149d3fcf1d2a (diff)
Add support for Source Hut's Mercurial hosting
Signed-off-by: Nicolas Paul <n@nc0.fr>
Diffstat (limited to 'pkg/config/lib/hg/hg.star')
-rw-r--r--pkg/config/lib/hg/hg.star34
1 files changed, 34 insertions, 0 deletions
diff --git a/pkg/config/lib/hg/hg.star b/pkg/config/lib/hg/hg.star
index 524578a..3cb647b 100644
--- a/pkg/config/lib/hg/hg.star
+++ b/pkg/config/lib/hg/hg.star
@@ -2,7 +2,41 @@
_MERCURIAL = "hg"
+_SOURCEHUT_DEFAULT_INSTANCE = "https://hg.sr.ht"
+_SOURCEHUT_DEFAULT_REV = "tip"
+
+def _sourcehut(
+ name,
+ user,
+ repo,
+ rev = _SOURCEHUT_DEFAULT_REV,
+ instance = _SOURCEHUT_DEFAULT_INSTANCE):
+ """Register a module hosted on a Mercurial repository on Source Hut.
+
+ Args:
+ name (str): The name of the module.
+ user (str): The name of the user or organization that owns the
+ repository.
+ repo (str): The name of the repository.
+ rev (str): The revision to use. Defaults to `hg.SOURCEHUT_DEFAULT_REV`.
+ instance (str): The instance of Source Hut to use.
+ Defaults to `hg.SOURCEHUT_DEFAULT_INSTANCE`.
+ """
+
+ module(
+ name = name,
+ vcs = _MERCURIAL,
+ repo = "%s/~%s/%s" % (instance, user, repo),
+ dir = "%s/~%s/%s/browse{/dir}?rev=%s" %
+ (instance, user, repo, rev),
+ file = "%s/~%s/%s/browse{/dir}/{file}?rev=%s#L{line}" %
+ (instance, user, repo, rev),
+ )
+
hg = make_module(
"hg",
MERCURIAL = _MERCURIAL,
+ SOURCEHUT_DEFAULT_INSTANCE = _SOURCEHUT_DEFAULT_INSTANCE,
+ SOURCEHUT_DEFAULT_REV = _SOURCEHUT_DEFAULT_REV,
+ sourcehut = _sourcehut,
)