bumperok 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/bin/bumper +20 -0
- data/lib/bumper.rb +37 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83feb89e71b699deb3abb1c4f9c3cac01b200283
|
4
|
+
data.tar.gz: d9052d093bd51d89cd932da8538da9491530b9c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5f1adfed5f9ff9d30720f2eec8baf16c7c53d82ff63f1778654e5a019211cdd86d205c877dd142787e92b6c6f38d146d282c278618ec8fd06e3cd3b01bbbd9e
|
7
|
+
data.tar.gz: e1ac64360f42f7221b8b2202a8ebce40c5f48c25aaad551989e1e34b033a6e7040540810c97961de7a139a2a971c27275213c70b33728c4caf99a3614d1be429
|
data/Rakefile
CHANGED
data/bin/bumper
CHANGED
@@ -33,6 +33,18 @@ OptionParser.new do |opts|
|
|
33
33
|
options.git_submodule = m
|
34
34
|
end
|
35
35
|
|
36
|
+
opts.on("-iPROJECT_ID", "--project-id=PROJECT_ID", "Project id for gitlab") do |p|
|
37
|
+
options.project_id = p
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on("-kKEY", "--key=KEY", "User key for gitlab") do |k|
|
41
|
+
options.key = k
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-eENDPOINT", "--endpoint=ENDPOINT", "Endpoint url for gitlab") do |e|
|
45
|
+
options.endpoint = e
|
46
|
+
end
|
47
|
+
|
36
48
|
end.parse!
|
37
49
|
|
38
50
|
case options.cmd
|
@@ -50,6 +62,14 @@ when 'submodule'
|
|
50
62
|
if options.git_url and options.git_submodule
|
51
63
|
Bumper.submodule_update_version("#{options.git_submodule[0].upcase}#{options.git_submodule[1..-1]}", options.git_submodule, options.git_url)
|
52
64
|
end
|
65
|
+
when 'merge'
|
66
|
+
if options.git_url and options.git_submodule and options.project_id
|
67
|
+
if options.endpoint
|
68
|
+
Bumper.create_merge_request_from_submodule(options.git_submodule, options.git_url, options.project_id, options.key, options.endpoint)
|
69
|
+
else
|
70
|
+
Bumper.create_merge_request_from_submodule(options.git_submodule, options.git_url, options.project_id, options.key)
|
71
|
+
end
|
72
|
+
end
|
53
73
|
else
|
54
74
|
raise "#{options.cmd} is unsupported command"
|
55
75
|
end
|
data/lib/bumper.rb
CHANGED
@@ -2,9 +2,10 @@ require 'git'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'git-ssh-wrapper'
|
4
4
|
require 'jenkins_api_client'
|
5
|
+
require 'gitlab'
|
5
6
|
|
6
7
|
class Bumper
|
7
|
-
VERSION = "0.0.
|
8
|
+
VERSION = "0.0.8"
|
8
9
|
|
9
10
|
def self.tag git_path, tag_name
|
10
11
|
wrapper = GitSSHWrapper.with_wrapper(private_key_path: '~/.ssh/bumber_at_sibext', log_level: 'ERROR') do |w|
|
@@ -37,11 +38,46 @@ class Bumper
|
|
37
38
|
`#{git(project_path)} checkout master`
|
38
39
|
`#{git(project_path)} branch -D UpdateFrom#{display}`
|
39
40
|
end
|
41
|
+
end
|
40
42
|
|
43
|
+
def self.create_merge_request_from_submodule submodule_name, git, gitlab_project_id, gitlab_key, gitlab_url='http://src.sibext.com/api/v3'
|
44
|
+
Gitlab.endpoint=gitlab_url
|
45
|
+
Gitlab.private_token=gitlab_key
|
46
|
+
begin
|
47
|
+
merge = Gitlab.merge_requests(gitlab_project_id).sort { |a,b| a.created_at <=> b.created_at }.last
|
48
|
+
rescue Gitlab::Error::NotFound => e
|
49
|
+
merge = nil
|
50
|
+
end
|
51
|
+
if merge
|
52
|
+
submodule_update_feature submodule_name, git, merge.source_branch
|
53
|
+
Gitlab.create_merge_request project_id, merge.title, source_branch: merge.source_branch, target_branch: 'master'
|
54
|
+
end
|
41
55
|
end
|
42
56
|
|
57
|
+
private
|
58
|
+
|
43
59
|
def self.git git_path
|
44
60
|
"git '--git-dir=#{git_path}/.git' '--work-tree=#{git_path}'"
|
45
61
|
end
|
46
62
|
|
63
|
+
def self.bumper_ssh &block
|
64
|
+
GitSSHWrapper.with_wrapper(private_key_path: '~/.ssh/bumber_at_sibext', log_level: 'ERROR', block)
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.submodule_update_feature name, git, branch
|
68
|
+
project_path = 'git_with_submodule'
|
69
|
+
bumper_ssh do |w|
|
70
|
+
w.set_env
|
71
|
+
`rm -Rf #{project_path}`
|
72
|
+
`git clone --recursive #{git} #{project_path}`
|
73
|
+
`#{git(project_path)} checkout -b #{branch}`
|
74
|
+
`cd #{project_path} && git submodule update --remote #{name}`
|
75
|
+
`#{git(project_path)} commit -am'New updates from #{name}'`
|
76
|
+
`#{git(project_path)} push --force origin #{branch}`
|
77
|
+
`#{git(project_path)} checkout master`
|
78
|
+
`#{git(project_path)} branch -D #{branch}`
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
|
47
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bumperok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikolay Moskvin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: gitlab
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rdoc
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|