diff options
author | Jonas Haag <jonas@lophus.org> | 2017-01-29 20:29:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-29 20:29:28 +0100 |
commit | 44b6ada1b78e86ef0c8bdfb9da3dc8f7167f4cea (patch) | |
tree | 82cda4a368bf24aa7bb96b85f56726f3562b65a9 | |
parent | 8df4deda16d2ad86a16e9f7ba406a323f5aa546c (diff) | |
parent | 8aacbdf548c4c65ef17d737d5f323080340d8192 (diff) |
Merge pull request #173 from jelmer/cloneurl
Support gitweb .git/cloneurl file and 'gitweb.url' settings.
-rw-r--r-- | klaus/repo.py | 12 | ||||
-rw-r--r-- | klaus/templates/history.inc.html | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/klaus/repo.py b/klaus/repo.py index 3ab506b..9ef383f 100644 --- a/klaus/repo.py +++ b/klaus/repo.py @@ -32,6 +32,18 @@ class FancyRepo(dulwich.repo.Repo): return refs[0].commit_time return None + @property + def cloneurl(self): + """Retrieve the gitweb notion of the public clone URL of this repo.""" + f = self.get_named_file('cloneurl') + if f is not None: + return f.read() + c = self.get_config() + try: + return force_unicode(c.get(b'gitweb', b'url')) + except KeyError: + return None + def get_description(self): """Like Dulwich's `get_description`, but returns None if the file contains Git's default text "Unnamed repository[...]". diff --git a/klaus/templates/history.inc.html b/klaus/templates/history.inc.html index f7b65bc..14afd26 100644 --- a/klaus/templates/history.inc.html +++ b/klaus/templates/history.inc.html @@ -37,6 +37,9 @@ {% if USE_SMARTHTTP %} <code>git clone {{ url_for('index', repo=repo.name, _external=True) }}</code> {% endif %} + {% if repo.cloneurl %} + <code>git clone {{ repo.cloneurl }}</code> + {% endif %} </h2> {{ pagination() }} |