summaryrefslogtreecommitdiff
path: root/pkg/config/lib/hg/hg.star
diff options
context:
space:
mode:
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,
)