gitlab_merge_request 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a758a214532e1d5540aae86d98603e80584de919
4
+ data.tar.gz: 455ad4f58ef0bf58beb90e66ab61e32408d4a33e
5
+ SHA512:
6
+ metadata.gz: 000f72a901c5a4124ecc475e3274ddf413d5e560aa8de56e8f052e2ccbf79ee46730d021286b8b5220c14d996abd031d8906963a598e7b77ef372516447b35af
7
+ data.tar.gz: 15af86916fba125de585d8b4aac2788323f34919e1bca86445af87bf70de4169bddec2373adb7ba93cba93f1761654d5bb5219d2242712c4ec4f9a137bef056b
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gitlab_merge_request.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ales Guzik
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # GitlabMergeRequest
2
+
3
+ Create GitLab merge requests from command line.
4
+
5
+ ## Installation
6
+
7
+ $ gem install gitlab_merge_request
8
+
9
+ ## Usage
10
+
11
+ Run
12
+
13
+ $ git mr
14
+
15
+ and follow the instructions.
16
+
17
+ ## Contributing
18
+
19
+ 1. Fork it ( https://github.com/alesguzik/gitlab_merge_request/fork )
20
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
21
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
22
+ 4. Push to the branch (`git push origin my-new-feature`)
23
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/git-mr ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+ require 'uri'
3
+ require 'awesome_print'
4
+
5
+ def git_config(key)
6
+ value = `git config --get #{key}`.chomp
7
+ if value.empty?
8
+ value = yield(key)
9
+ puts "Set #{key} = #{value}"
10
+ system "git config #{key} #{value}"
11
+ end
12
+ value
13
+ end
14
+
15
+ ssh_url = URI(`git config --get remote.origin.url`)
16
+ api_endpoint = git_config 'gitlab.api-endpoint' do
17
+ "http://#{ssh_url.host}/api/v3/"
18
+ end
19
+ ENV['GITLAB_API_ENDPOINT'] = api_endpoint
20
+
21
+ token = git_config 'gitlab.private-token' do |key|
22
+ puts <<-EOF
23
+ Please run:
24
+ git config #{key} YOUR_TOKEN
25
+ You can get your token at http://#{URI(api_endpoint).host}/profile/account
26
+ EOF
27
+ exit 1
28
+ end
29
+ ENV['GITLAB_API_PRIVATE_TOKEN'] = token
30
+
31
+ require 'gitlab'
32
+
33
+ project_id = git_config 'gitlab.project-id' do
34
+ Gitlab.projects.select{|prj| prj.ssh_url_to_repo == ssh_url.to_s}.first.id
35
+ end
36
+
37
+ source_branch = %x(git rev-parse --abbrev-ref HEAD).chomp
38
+ target_branch = git_config 'gitlab.merge-request-target' do
39
+ Gitlab.project(project_id).default_branch
40
+ end
41
+
42
+ task_url_template = git_config 'gitlab.task-url-template' do
43
+ "http://jira.softswiss.com/browse/CASINO-%s"
44
+ end
45
+
46
+ print "Creating merge request.
47
+
48
+ From: #{source_branch}
49
+ To: #{target_branch}
50
+ Title: "
51
+ title = gets.chomp
52
+ task_id = $1 if source_branch.match(/\At(\d+)_/)
53
+
54
+ if task_id
55
+ note_text = "#{task_url_template % task_id}\n"
56
+ end
57
+
58
+ print "Text:
59
+ #{note_text}"
60
+ additional_text = STDIN.read.chomp
61
+ note_text = (note_text.to_s + additional_text).chomp
62
+
63
+ puts "Going to create merge request with following data (blank note will not be created):"
64
+ ap source_branch: source_branch,
65
+ target_branch: target_branch,
66
+ title: title,
67
+ note_text: note_text
68
+ puts "Proceed? [Y/n]"
69
+ answer = gets
70
+
71
+ case answer
72
+ when nil,/[Nn]/
73
+ puts "Merge request aborted"
74
+ when "\n", /[Yy]/
75
+ mr = Gitlab.create_merge_request(
76
+ project_id,
77
+ title,
78
+ source_branch: source_branch,
79
+ target_branch: target_branch)
80
+ Gitlab.create_note("#{project_id}/merge_requests/#{mr.id}", note_text) unless note_text.blank?
81
+ mr_url = "#{Gitlab.project(project_id).web_url}/merge_requests/#{mr.id}"
82
+ puts "Created merge request: #{mr_url}"
83
+ end
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env ruby
2
+ require 'uri'
3
+ require 'awesome_print'
4
+
5
+ def git_config(key)
6
+ value = `git config --get #{key}`.chomp
7
+ if value.empty?
8
+ value = yield(key)
9
+ puts "Set #{key} = #{value}"
10
+ system "git config #{key} #{value}"
11
+ end
12
+ value
13
+ end
14
+
15
+ ssh_url = URI(`git config --get remote.origin.url`)
16
+ api_endpoint = git_config 'gitlab.api-endpoint' do
17
+ "http://#{ssh_url.host}/api/v3/"
18
+ end
19
+ ENV['GITLAB_API_ENDPOINT'] = api_endpoint
20
+
21
+ token = git_config 'gitlab.private-token' do |key|
22
+ puts <<-EOF
23
+ Please run:
24
+ git config #{key} YOUR_TOKEN
25
+ You can get your token at http://#{URI(api_endpoint).host}/profile/account
26
+ EOF
27
+ exit 1
28
+ end
29
+ ENV['GITLAB_API_PRIVATE_TOKEN'] = token
30
+
31
+ require 'gitlab'
32
+
33
+ project_id = git_config 'gitlab.project-id' do
34
+ Gitlab.projects.select{|prj| prj.ssh_url_to_repo == ssh_url.to_s}.first.id
35
+ end
36
+
37
+ source_branch = %x(git rev-parse --abbrev-ref HEAD).chomp
38
+ target_branch = git_config 'gitlab.merge-request-target' do
39
+ Gitlab.project(project_id).default_branch
40
+ end
41
+
42
+ task_url_template = git_config 'gitlab.task-url-template' do
43
+ "http://jira.softswiss.com/browse/CASINO-%s"
44
+ end
45
+
46
+ print "Creating merge request.
47
+
48
+ From: #{source_branch}
49
+ To: #{target_branch}
50
+ Title: "
51
+ title = gets.chomp
52
+ task_id = $1 if source_branch.match(/\At(\d+)_/)
53
+
54
+ if task_id
55
+ note_text = "#{task_url_template % task_id}\n"
56
+ end
57
+
58
+ print "Text:
59
+ #{note_text}"
60
+ additional_text = STDIN.read.chomp
61
+ note_text = (note_text.to_s + additional_text).chomp
62
+
63
+ puts "Going to create merge request with following data (blank note will not be created):"
64
+ ap source_branch: source_branch,
65
+ target_branch: target_branch,
66
+ title: title,
67
+ note_text: note_text
68
+ puts "Proceed? [Y/n]"
69
+ answer = gets
70
+
71
+ case answer
72
+ when nil,/[Nn]/
73
+ puts "Merge request aborted"
74
+ when "\n", /[Yy]/
75
+ mr = Gitlab.create_merge_request(
76
+ project_id,
77
+ title,
78
+ source_branch: source_branch,
79
+ target_branch: target_branch)
80
+ Gitlab.create_note("#{project_id}/merge_requests/#{mr.id}", note_text) unless note_text.blank?
81
+ mr_url = "#{Gitlab.project(project_id).web_url}/merge_requests/#{mr.id}"
82
+ puts "Created merge request: #{mr_url}"
83
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitlab_merge_request/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gitlab_merge_request"
8
+ spec.version = GitlabMergeRequest::VERSION
9
+ spec.authors = ["Ales Guzik"]
10
+ spec.email = ["me@aguzik.net"]
11
+ spec.summary = %q{Make GitLab merge request}
12
+ spec.description = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "gitlab", ">= 3.2.0"
22
+ spec.add_dependency "awesome_print", ">= 1.2.0"
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,3 @@
1
+ module GitlabMergeRequest
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "gitlab_merge_request/version"
2
+
3
+ module GitlabMergeRequest
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitlab_merge_request
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ales Guzik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gitlab
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: awesome_print
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: ''
70
+ email:
71
+ - me@aguzik.net
72
+ executables:
73
+ - git-mr
74
+ - gitlab_merge_request
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/git-mr
84
+ - bin/gitlab_merge_request
85
+ - gitlab_merge_request.gemspec
86
+ - lib/gitlab_merge_request.rb
87
+ - lib/gitlab_merge_request/version.rb
88
+ homepage: ''
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.2.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Make GitLab merge request
112
+ test_files: []