From 71dc3b30449a4574455ff7eb9c390e30ad52ac4a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 15 Dec 2016 16:01:03 -0500 Subject: fix (wip) --- git-mirror-cgit | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'git-mirror-cgit') 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) -- cgit v1.2.3