summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Paul <n@nc0.fr>2023-06-01 11:38:29 +0200
committerNicolas Paul <n@nc0.fr>2023-06-01 11:38:29 +0200
commit9d0ba6d46d7101199bf65b00145e149d3fcf1d2a (patch)
tree7acb56051f01db0aaca4c8161e8599fc6dc6e852
parentff455f41831572e705580162fada56f1f194bd0c (diff)
Add Launchpad's Bazaar hosting support
Signed-off-by: Nicolas Paul <n@nc0.fr>
-rw-r--r--doc/references.md36
-rw-r--r--pkg/config/lib/bzr/bzr.star39
2 files changed, 75 insertions, 0 deletions
diff --git a/doc/references.md b/doc/references.md
index 4ed10dc..ddd380a 100644
--- a/doc/references.md
+++ b/doc/references.md
@@ -160,6 +160,40 @@ module(
)
```
+### bzr.LAUNCHPAD_DEFAULT_INSTANCE
+
+`"https://bazaar.launchpad.net` \
+A constant containing the default instance of the
+[Launchpad Bazaar hosting][launchpad-bzr-link] service.
+
+### bzr.LAUNCHPAD_DEFAULT_REV
+
+`"head:"` \
+A constant containing the default revision number to use when the repository
+is hosted on [Launchpad Bazaar hosting][launchpad-bzr-link] service.
+
+### bzr.LAUNCHPAD_DEFAULT_BRANCH
+
+`"trunk"` \
+A constant containing the default branch name to use when the repository
+is hosted on [Launchpad Bazaar hosting][launchpad-bzr-link] service.
+
+### bzr.launchpad
+
+A macro that registers a module hosted on
+[Launchpad Bazaar hosting][launchpad-bzr-link] service.
+
+#### Parameters
+
+| Name | Type | Description |
+|------------|----------|-------------------------------------------------------------------------------------------------------------------|
+| `name` | `string` | The name of the module. |
+| `user` | `string` | The name of the user or organization that owns the repository. |
+| `repo` | `string` | The name of the repository. |
+| `branch` | `string` | The name of the branch. Defaults to [`bzr.LAUNCHPAD_DEFAULT_BRANCH`](#bzrlaunchpad_default_branch) |
+| `rev` | `string` | The revision number. Defaults to [`bzr.LAUNCHPAD_DEFAULT_REV`](#bzrlaunchpad_default_rev) |
+| `instance` | `string` | The URL of the Launchpad instance. Defaults to [`bzr.LAUNCHPAD_DEFAULT_INSTANCE`](#bzrlaunchpad_default_instance) |
+
## Fossil
The [fossil](../pkg/config/lib/fossil/fossil.star) module contains a set
@@ -574,3 +608,5 @@ module(
[starlark-go]: https://github.com/google/starlark-go
[bazel-link]: https://bazel.build/
+
+[launchpad-bzr-link]: https://launchpad.net/bzr
diff --git a/pkg/config/lib/bzr/bzr.star b/pkg/config/lib/bzr/bzr.star
index 2376f18..e53a089 100644
--- a/pkg/config/lib/bzr/bzr.star
+++ b/pkg/config/lib/bzr/bzr.star
@@ -2,7 +2,46 @@
_BAZAAR = "bzr"
+_LAUNCHPAD_DEFAULT_INSTANCE = "https://bazaar.launchpad.net"
+_LAUNCHPAD_DEFAULT_REV = "head:"
+_LAUNCHPAD_DEFAULT_BRANCH = "trunk"
+
+def _launchpad(
+ name,
+ user,
+ repo,
+ branch = _LAUNCHPAD_DEFAULT_BRANCH,
+ rev = _LAUNCHPAD_DEFAULT_REV,
+ instance = _LAUNCHPAD_DEFAULT_INSTANCE):
+ """Register a module hosted on Launchpad.
+
+ Args:
+ name (str): The name of the module.
+ user (str): The ID of the user.
+ repo (str): The name of the repository.
+ branch (str): The name of the branch.
+ Defaults to `bzr.LAUNCHPAD_DEFAULT_BRANCH`.
+ rev (str): The revision number.
+ Defaults to `bzr.LAUNCHPAD_DEFAULT_REV`.
+ instance (str): The name of the instance.
+ Defaults to `bzr.LAUNCHPAD_DEFAULT_INSTANCE`.
+ """
+
+ return module(
+ name = name,
+ vcs = _BAZAAR,
+ repo = "%s/~%s/%s/%s" % (instance, user, repo, branch),
+ dir = "%s/~%s/%s/%s/files/%s{/dir}" %
+ (instance, user, repo, branch, rev),
+ file = "%s/~%s/%s/%s/view/%s{/dir}/{file}#L{line}" %
+ (instance, user, repo, branch, rev),
+ )
+
bzr = make_module(
"bzr",
BAZAR = _BAZAAR,
+ LAUNCHPAD_DEFAULT_INSTANCE = _LAUNCHPAD_DEFAULT_INSTANCE,
+ LAUNCHPAD_DEFAULT_REV = _LAUNCHPAD_DEFAULT_REV,
+ LAUNCHPAD_DEFAULT_BRANCH = _LAUNCHPAD_DEFAULT_BRANCH,
+ launchpad = _launchpad,
)