代码拉取完成,页面将自动刷新
同步操作将从 openEuler/openEuler-Advisor 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/ruby
require 'yaml'
require 'json'
require 'date'
require './check_upstream/github'
require './check_upstream/git'
require './check_upstream/hg'
require './check_upstream/svn'
require './check_upstream/metacpan'
require './check_upstream/gnome'
require './check_upstream/pypi'
Prj_name = ARGV[0]
Cur_ver = ARGV[1]
Prj_info = YAML.load(File.read "upstream-info/"+Prj_name+".yaml")
def compare_tags (a, b)
arr_a = a.split(".")
arr_b = b.split(".")
len = [arr_a.length, arr_b.length].min
idx = 0
while idx < len do
res1 = arr_a[idx].to_i <=> arr_b[idx].to_i
return res1 if res1 != 0
res2 = arr_a[idx].length <=> arr_b[idx].length
return -res2 if res2 != 0
res3 = arr_a[idx][-1].to_i <=> arr_b[idx][-1].to_i
return res3 if res3 != 0
idx = idx + 1
end
return arr_a.length <=> arr_b.length
end
def sort_tags (tags)
tags.sort! { |a, b|
compare_tags(a,b)
}
return tags
end
def clean_tags(tags)
new_tags = []
tags.each{|line|
new_tags = new_tags.push(clean_tag(line, Prj_info))
}
return new_tags
end
def upgrade_recommend(tags_param, cur_tag, policy)
tags = tags_param.reverse
tag1 = cur_tag
tag2 = cur_tag
if policy == "latest" then
return tags[0]
elsif policy == "latest-stable" then
tags.each { |tag|
if tag.split(".").count {|f| f.to_i != 0 } >= 3 then
tag1 = tag
break
end
}
tags.each { |tag|
if tag.split(".").count {|f| f.to_i != 0} >= 2 then
tag2 = tag
break
end
}
if tag2[0].to_i > tag1[0].to_i then
return tag2
else
return tag1
end
elsif policy == "perfer-stable" then
tags.each { |tag|
if tag.start_with?(cur_tag) then
return tag
end
}
if cur_tag.split(".").length >= 3 then
search_tag = cur_tag.split(".")[0..1].join(".")
tags.each { |tag|
if tag.start_with?(search_tag) then
return tag
end
}
end
return cur_tag
else
return cur_tag
end
end
print Prj_name, ":\n"
if Prj_info["version_control"] == "svn" then
tags = check_upstream_svn(Prj_info)
elsif Prj_info["version_control"] == "github" then
tags = check_upstream_github_by_api(Prj_info)
if tags == nil or tags == "" then
tags = check_upstream_github_by_git(Prj_info)
end
tags = clean_tags(tags.lines)
elsif Prj_info["version_control"] == "git" then
tags = check_upstream_git(Prj_info)
tags = clean_tags(tags.lines)
elsif Prj_info["version_control"] == "hg" then
tags = check_upstream_hg(Prj_info)
tags = clean_tags(tags.lines)
elsif Prj_info["version_control"] == "metacpan" then
tags = check_upstream_metacpan(Prj_info)
tags = clean_tags(tags.lines)
elsif Prj_info["version_control"] == "gitlab.gnome" then
tags = check_upstream_gnome(Prj_info)
tags = clean_tags(tags.lines)
elsif Prj_info["version_control"] == "pypi" then
tags = check_upstream_pypi(Prj_info)
tags = clean_tags(tags.lines)
end
tags = sort_tags(tags)
print "Latest upstream is ", tags[-1], "\n"
print "Recommended is ", upgrade_recommend(tags, Cur_ver, "latest-stable"), "\n"
print "Current version is ", Cur_ver, "\n"
if tags.length == 0 or compare_tags(tags[-1], Cur_ver) < 0 then
STDERR.puts "DEBUG #{Prj_name} > tags are #{tags}"
File.delete("upstream-info/"+Prj_name+".yaml") if File.exist?("upstream-info/"+Prj_name+".yaml")
File.open("known-issues/"+Prj_name+".yaml", "w") { |file| file.write(Prj_info.to_yaml) }
else
File.open("upstream-info/"+Prj_name+".yaml", "w") { |file| file.write(Prj_info.to_yaml) }
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。