diff options
| author | Kamil Trzciński <ayufan@ayufan.eu> | 2015-09-16 11:57:40 +0000 |
|---|---|---|
| committer | Kamil Trzciński <ayufan@ayufan.eu> | 2015-09-16 11:57:40 +0000 |
| commit | cccd269da3f5d82c5d14289980d9b52c9cad08db (patch) | |
| tree | 2947658dfff44a3873f7d350f0353dbdb7b9b541 /lib/ci/version_info.rb | |
| parent | 7d59ba00b9aa1a8be28f1b7ccaa1c628be90aabb (diff) | |
| parent | ac8d2eb065e9522679d4eae4649c6815daa5460c (diff) | |
| download | gitlab-ce-cccd269da3f5d82c5d14289980d9b52c9cad08db.tar.gz | |
Merge branch 'ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g' into 'master'
Merge CI into CE
First step of #2164.
- [x] Merge latest CE master
- [x] Make application start
- [x] Re-use gitlab sessions (remove CI oauth part)
- [x] Get rid of gitlab_ci.yml config
- [x] Make tests start
- [x] Make most CI features works
- [x] Make tests green
- [x] Write migration documentation
- [x] Add CI builds to CE backup
See merge request !1204
Diffstat (limited to 'lib/ci/version_info.rb')
| -rw-r--r-- | lib/ci/version_info.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/ci/version_info.rb b/lib/ci/version_info.rb new file mode 100644 index 00000000000..2a87c91db5e --- /dev/null +++ b/lib/ci/version_info.rb @@ -0,0 +1,52 @@ +class VersionInfo + include Comparable + + attr_reader :major, :minor, :patch + + def self.parse(str) + if str && m = str.match(/(\d+)\.(\d+)\.(\d+)/) + VersionInfo.new(m[1].to_i, m[2].to_i, m[3].to_i) + else + VersionInfo.new + end + end + + def initialize(major = 0, minor = 0, patch = 0) + @major = major + @minor = minor + @patch = patch + end + + def <=>(other) + return unless other.is_a? VersionInfo + return unless valid? && other.valid? + + if other.major < @major + 1 + elsif @major < other.major + -1 + elsif other.minor < @minor + 1 + elsif @minor < other.minor + -1 + elsif other.patch < @patch + 1 + elsif @patch < other.patch + -1 + else + 0 + end + end + + def to_s + if valid? + "%d.%d.%d" % [@major, @minor, @patch] + else + "Unknown" + end + end + + def valid? + @major >= 0 && @minor >= 0 && @patch >= 0 && @major + @minor + @patch > 0 + end +end |
