diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-06-19 13:52:46 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-06-19 13:52:46 -0400 |
commit | b9fe143cf2503a180a636e131928735c4266b01f (patch) | |
tree | 2590d91a25a62a4a36a8817990a98218e548c40c | |
parent | 1d949b18b2dc4f52551aaef80f6ffb2d85621da4 (diff) |
-rwxr-xr-x | git-mirror-cgit | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/git-mirror-cgit b/git-mirror-cgit index 5e6cfc6..5c56993 100755 --- a/git-mirror-cgit +++ b/git-mirror-cgit @@ -33,11 +33,17 @@ class Cgit < GitMirrorBackend def cmd_get_meta(path) doc = self.getHTML(path) - head = open(@config['url']+(path+'/HEAD')).read + empty = (doc.css('.error').text == "Repository seems to be empty") + if empty + default_branch = 'master' + else + head = open(@config['url']+(path+'/HEAD')).read + default_branch = head.split("\n")[0].sub(/^ref: /, '').sub(/^refs\/heads\//, '') + end return { 'description' => doc.css('#header .sub')[0].text, 'owner' => doc.css('#header .sub')[1].text, - 'default-branch' => head.split("\n")[0].sub(/^ref: /, '').sub(/^refs\/heads\//, ''), + 'default-branch' => default_branch, } end |