diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-04 19:01:13 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-04 19:01:13 +0300 |
commit | 928786559964c3fc103fa13bddd571777f97a666 (patch) | |
tree | 3bc13fa0c735cb54c58bd05b9530973d41fc96c1 /lib | |
parent | b9219469f759f387a35bec39c3dc59477793ef1b (diff) | |
parent | 6181160504da5e43e9a15c37bdad96741b53a39c (diff) |
Merge branch 'fix-upgrader-script' into 'master'
Fix upgrader script
This is a fix for upgrader script not guessing the latest version correctly.
Upgrader now handles versions where a version part (major/minor/patch) can have multi-digit number, also ensures that the latest version is chosen from git tags by converting tag to Gitlab::VersionInfo and than selecting the latest/greatest version.
Fixes: #1476
See merge request !695
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/upgrader.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/gitlab/upgrader.rb b/lib/gitlab/upgrader.rb index 0570c2fbeb5..cf040971c6e 100644 --- a/lib/gitlab/upgrader.rb +++ b/lib/gitlab/upgrader.rb @@ -43,10 +43,15 @@ module Gitlab end def latest_version_raw + git_tags = fetch_git_tags + git_tags = git_tags.select { |version| version =~ /v\d+\.\d+\.\d+\Z/ } + git_versions = git_tags.map { |tag| Gitlab::VersionInfo.parse(tag.match(/v\d+\.\d+\.\d+/).to_s) } + "v#{git_versions.sort.last.to_s}" + end + + def fetch_git_tags remote_tags, _ = Gitlab::Popen.popen(%W(git ls-remote --tags https://gitlab.com/gitlab-org/gitlab-ce.git)) - git_tags = remote_tags.split("\n").grep(/tags\/v#{current_version.major}/) - git_tags = git_tags.select { |version| version =~ /v\d\.\d\.\d\Z/ } - last_tag = git_tags.last.match(/v\d\.\d\.\d/).to_s + remote_tags.split("\n").grep(/tags\/v#{current_version.major}/) end def update_commands |