aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2021-08-01 16:49:35 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2021-08-01 16:49:35 +0300
commit3cb857219881668bfddafcade1cecb1113f32de6 (patch)
tree10b50b60c3e9bec866c55f6913a9b0cc24284757
parentworkflows/ci: separate job for examples/cgitize.toml (diff)
downloadcgitize-3cb857219881668bfddafcade1cecb1113f32de6.tar.gz
cgitize-3cb857219881668bfddafcade1cecb1113f32de6.zip
support setting "dir" for individual repositories
-rw-r--r--cgitize/config.py8
-rw-r--r--cgitize/repo.py4
-rw-r--r--examples/cgitize.toml6
-rwxr-xr-xtest/integration/example/test.sh20
4 files changed, 25 insertions, 13 deletions
diff --git a/cgitize/config.py b/cgitize/config.py
index 35ba05f..2f074bb 100644
--- a/cgitize/config.py
+++ b/cgitize/config.py
@@ -130,6 +130,10 @@ class HostedRepo:
def id(self):
return self._impl['id']
+ @property
+ def dir(self):
+ return self._impl.get('dir')
+
class Config:
DEFAULT_PATH = '/etc/cgitize/cgitize.toml'
@@ -155,7 +159,7 @@ class Config:
github = GitHub(self.github.access_token)
for r in self.github.repositories.enum_repositories():
r = HostedRepo(r)
- yield Repo.from_github(github.get_repo(r), self)
+ yield Repo.from_github(github.get_repo(r), self, r.dir)
for u in self.github.users.enum_users():
u = User(u)
yield from (Repo.from_github(r, self, u.dir) for r in github.get_user_repos(u))
@@ -164,7 +168,7 @@ class Config:
bitbucket = Bitbucket(self.bitbucket.username, self.bitbucket.app_password)
for r in self.bitbucket.repositories.enum_repositories():
r = HostedRepo(r)
- yield Repo.from_bitbucket(bitbucket.get_repo(r), self)
+ yield Repo.from_bitbucket(bitbucket.get_repo(r), self, r.dir)
for u in self.bitbucket.users.enum_users():
u = User(u)
yield from (Repo.from_bitbucket(r, self, u.dir) for r in bitbucket.get_user_repos(u))
diff --git a/cgitize/repo.py b/cgitize/repo.py
index cce3209..133cdc8 100644
--- a/cgitize/repo.py
+++ b/cgitize/repo.py
@@ -20,7 +20,9 @@ class Repo:
if 'clone_url' not in src:
raise ValueError("every repository must have 'clone_url'")
clone_url = src['clone_url']
- return Repo(name, clone_url, owner=owner, desc=desc, homepage=homepage)
+ subdir = src.get('dir')
+ return Repo(name, clone_url, owner=owner, desc=desc, homepage=homepage,
+ subdir=subdir)
@staticmethod
def from_github(src, config, subdir=None):
diff --git a/examples/cgitize.toml b/examples/cgitize.toml
index 19b7056..e789875 100644
--- a/examples/cgitize.toml
+++ b/examples/cgitize.toml
@@ -31,6 +31,8 @@ dir = "github-dir"
id = "ekmett/lens"
[github.repositories.pytomlpp]
id = "bobfang1992/pytomlpp"
+# You can put repositories in a subdirectory:
+dir = "python"
[bitbucket]
# If some of the repositories hosted on Bitbucket are private, you can use "app
@@ -51,6 +53,8 @@ dir = "bitbucket-dir"
# Some random repositories hosted on Bitbucket:
[bitbucket.repositories.cef]
id = "chromiumembedded/cef"
+# You can put repositories in a subdirectory:
+dir = "chromiumembedded"
[bitbucket.repositories.upc-runtime]
id = "berkeleylab/upc-runtime"
@@ -62,3 +66,5 @@ name = "wintun"
clone_url = "https://git.zx2c4.com/wintun"
owner = "Jason A. Donenfeld"
desc = "Layer 3 TUN Driver for Windows"
+# You can put repositories in a subdirectory:
+dir = "wireguard"
diff --git a/test/integration/example/test.sh b/test/integration/example/test.sh
index b8135f5..ee5656d 100755
--- a/test/integration/example/test.sh
+++ b/test/integration/example/test.sh
@@ -121,13 +121,13 @@ test_ssh() {
setup_ssh
cgitize
verify_repos \
- lens \
- cef \
- wintun \
+ lens \
+ chromiumembedded/cef \
+ wireguard/wintun \
github-dir/cgitize-test-repository \
bitbucket-dir/cgitize-test-repository
verify_origin lens 'git@github.com:ekmett/lens.git'
- verify_origin cef 'git@bitbucket.org:chromiumembedded/cef.git'
+ verify_origin chromiumembedded/cef 'git@bitbucket.org:chromiumembedded/cef.git'
verify_origin github-dir/cgitize-test-repository 'git@github.com:egor-tensin/cgitize-test-repository.git'
verify_origin bitbucket-dir/cgitize-test-repository 'git@bitbucket.org:egor-tensin/cgitize-test-repository.git'
cleanup
@@ -142,13 +142,13 @@ test_https() {
setup_https
cgitize
verify_repos \
- lens \
- cef \
- wintun \
+ lens \
+ chromiumembedded/cef \
+ wireguard/wintun \
github-dir/cgitize-test-repository \
bitbucket-dir/cgitize-test-repository
verify_origin lens 'https://github.com/ekmett/lens.git'
- verify_origin cef 'https://bitbucket.org/chromiumembedded/cef.git'
+ verify_origin chromiumembedded/cef 'https://bitbucket.org/chromiumembedded/cef.git'
verify_origin github-dir/cgitize-test-repository 'https://github.com/egor-tensin/cgitize-test-repository.git'
verify_origin bitbucket-dir/cgitize-test-repository 'https://bitbucket.org/egor-tensin/cgitize-test-repository.git'
cleanup
@@ -162,8 +162,8 @@ test_one_repo() {
setup_https
cgitize --repo cef
- verify_repos cef
- verify_no_repos lens wintun
+ verify_repos chromiumembedded/cef
+ verify_no_repos lens wireguard/wintun
cleanup
}