From eea76850125119ca79c891f94aa422c96eb25b27 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 6 Jan 2019 23:58:06 +0000 Subject: fall back to cgit_url and git_url if "source_code" is not defined Some projects are too lazy to update or upgrade, but cgit/git URLs are "git clone"-able. --- lib/oldweb.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/oldweb.rb b/lib/oldweb.rb index daa5cc5..ccc37f7 100644 --- a/lib/oldweb.rb +++ b/lib/oldweb.rb @@ -73,7 +73,19 @@ class Oldweb noindex = @old_cfg['noindex'] and noindex.each { |k| ni[k] = true } @old_cfg['noindex'] = ni - if cgit_url = @old_cfg['cgit_url'] + cgit_url = @old_cfg['cgit_url'] + source = @old_cfg['source_code'] ||= [] + if source.empty? + if cgit_url + source << "git clone #{cgit_url}" + end + git_url = @old_cfg['git_url'] + if git_url && git_url != cgit_url + source << "git clone #{git_url}" + end + end + + if cgit_url cgit_url += '/tree/%s' # path name tag = @git_tag and cgit_url << "id=#{URI.escape(tag)}" cgit_url << '#n%d' # lineno -- cgit v1.2.3-24-ge0c7