diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-12-15 16:01:03 -0500 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-12-15 16:01:03 -0500 |
commit | 71dc3b30449a4574455ff7eb9c390e30ad52ac4a (patch) | |
tree | 2f294aeb109bd4049876a598eaf9a43379c1fb90 /git-mirror-cgit | |
parent | a043ff3446cce1e7000cf76bc227f9260199fce3 (diff) |
fix (wip)
Diffstat (limited to 'git-mirror-cgit')
-rwxr-xr-x | git-mirror-cgit | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/git-mirror-cgit b/git-mirror-cgit index 8c1b799..3a953b2 100755 --- a/git-mirror-cgit +++ b/git-mirror-cgit @@ -23,15 +23,16 @@ class Cgit < GitMirrorBackend end @config[key] = val end + return nil end def cmd_get_meta(path) - doc = Nokogiri::HTML(open(@config[url]+path)) - head = open(@config[url]+path+'/HEAD').read + doc = Nokogiri::HTML(open(@config['url']+path)) + head = open(@config['url']+(path+'/HEAD')).read 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' => head.split("\n")[0].sub(/^ref: /, '').sub(/^refs\/heads\//, ''), } end @@ -40,20 +41,20 @@ class Cgit < GitMirrorBackend end def urls(path) - doc = Nokogiri::HTML(open(@config[url]+path)) + doc = Nokogiri::HTML(open(@config['url']+path)) return doc.css('a[rel="vcs-git"]').map{|a| a['href']} end def cmd_push_url(path) prefs = ['ssh', 'https', 'http', 'git'] - return self.urls.sort_by{|url| prefs.index(url)} + return self.urls(path).sort_by{|u| prefs.index(u.split(':', 2)[0])}.first end def cmd_pull_url(path) # prefer https ahead of git because of a bug in git-daemon # with '~'. prefs = ['https', 'git', 'http', 'ssh'] - return self.urls.sort_by{|url| prefs.index(url)} + return self.urls(path).sort_by{|u| prefs.index(u.split(':', 2)[0])}.first end def cmd_repo_mode(path) |