gitx 3.0.2 → 3.2.0.ci.231.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1077ebb26e155a2ddaeca39eaa8afc89a5a6cd09
4
- data.tar.gz: eabb5c99e9bdaac5512bfca7714a245cfb8d9b1c
2
+ SHA256:
3
+ metadata.gz: 5b8587ddcc46ef139e7da6a96c086a1a22d36f3deeeaef1fe1ca821e715788fc
4
+ data.tar.gz: 4d6438cd1e56cdc71a884166c2fddf6c83603394a1ff955f56b64936cb8d9dde
5
5
  SHA512:
6
- metadata.gz: 6f0b0ade0d34b6d74cb77e6a3d49be8cea9fd1dfaffaf09038f8dec08bf21509263e3251cbbb9e35380a474851a0361884af6914e32de99b3fd88c5b74b324a9
7
- data.tar.gz: fc1c96391e0ccecc7269ae3bb752ce8693f2f8788cde9f6336b1a225a9f9048d22d298f7425e526ca0a3f275ccd9b91ef5c50f8018fc5a433c761535b95c6375
6
+ metadata.gz: 2654037ef33ad4715d93a8c3d24b0c7b9ee592b57f1200529bf46251481574b57df694d2832af190dd2efc6be2db63d7e327c79add1db503e325055264469196
7
+ data.tar.gz: 82fae8f49f8db3ee90166dae76f5143cbedb34f2553307a571dae4894bd6831910f3d64a13d0cc8410a472f5a9060df347134029fb2d2626fdf0edcd8d9aa2b4
data/.rubocop.yml CHANGED
@@ -6,6 +6,9 @@
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ AllCops:
10
+ TargetRubyVersion: '2.6'
11
+
9
12
  FileName:
10
13
  Exclude:
11
14
  - bin/*
@@ -25,7 +28,7 @@ Metrics/AbcSize:
25
28
 
26
29
  # Offense count: 2
27
30
  Metrics/CyclomaticComplexity:
28
- Max: 7
31
+ Max: 8
29
32
 
30
33
  # Offense count: 5
31
34
  # Configuration parameters: CountComments.
@@ -35,7 +38,7 @@ Metrics/MethodLength:
35
38
  # Offense count: 1
36
39
  # Configuration parameters: CountComments.
37
40
  Metrics/ModuleLength:
38
- Max: 123
41
+ Max: 150
39
42
 
40
43
  # Offense count: 3
41
44
  Style/RescueModifier:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.1
1
+ 2.7.3
data/README.md CHANGED
@@ -47,13 +47,13 @@ This setting is cleared when a reviewer approves or rejects the pull request.
47
47
 
48
48
  ## git release <feature_branch_name (optional, default: current_branch)
49
49
 
50
- release the feature branch to master. This operation will perform the following:
50
+ release the feature branch to the base branch (by default, master). This operation will perform the following:
51
51
 
52
52
  * pull latest code from remote feature branch
53
- * pull latest code from master branch
53
+ * pull latest code from the base branch
54
54
  * prompt user to confirm they actually want to perform the release
55
55
  * check if pull request commit status is currently successful
56
- * merge current branch into master
56
+ * merge current branch into the base branch (or add release label if configured)
57
57
  * (optional) cleanup merged branches from remote server
58
58
 
59
59
  options:
@@ -63,7 +63,7 @@ options:
63
63
 
64
64
  ## git cleanup
65
65
 
66
- delete released branches after they have been merged into master.
66
+ delete released branches after they have been merged into the base branch.
67
67
 
68
68
  ## git nuke <aggregate_branch_name>
69
69
 
data/gitx.gemspec CHANGED
@@ -1,40 +1,38 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'gitx/version'
6
4
 
7
5
  Gem::Specification.new do |spec|
8
- spec.name = 'gitx'
9
- spec.version = Gitx::VERSION
10
- spec.authors = ['Ryan Sonnek']
11
- spec.email = ['ryan.sonnek@gmail.com']
12
- spec.description = 'Git eXtensions for improved development workflows'
13
- spec.summary = 'Utility scripts for Git to increase productivity for common operations'
14
- spec.homepage = ''
15
- spec.license = 'MIT'
6
+ spec.name = 'gitx'
7
+ spec.authors = ['Ryan Sonnek']
8
+ spec.email = ['ryan.sonnek@gmail.com']
9
+ spec.description = 'Git eXtensions for improved development workflows'
10
+ spec.summary = 'Utility scripts for Git to increase productivity for common operations'
11
+ spec.homepage = ''
12
+ spec.license = 'MIT'
13
+ spec.required_ruby_version = '>= 2.6.7'
16
14
 
17
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ['lib']
15
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
21
19
 
22
- spec.add_runtime_dependency 'rugged', '~> 0.26.0'
23
- spec.add_runtime_dependency 'thor'
24
20
  spec.add_runtime_dependency 'octokit'
21
+ spec.add_runtime_dependency 'rugged', '~> 0.27.10'
22
+ spec.add_runtime_dependency 'thor'
25
23
 
26
24
  spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'coveralls'
26
+ spec.add_development_dependency 'pry'
27
27
  spec.add_development_dependency 'rake'
28
28
  spec.add_development_dependency 'rspec', '>= 3.0'
29
- spec.add_development_dependency 'pry'
30
- spec.add_development_dependency 'webmock'
29
+ spec.add_development_dependency 'rubocop'
31
30
  spec.add_development_dependency 'timecop'
32
31
  spec.add_development_dependency 'vcr'
33
- spec.add_development_dependency 'coveralls'
34
- spec.add_development_dependency 'rubocop'
32
+ spec.add_development_dependency 'webmock'
35
33
 
36
34
  # configure gem version for continuous integration builds
37
- if ENV['TRAVIS_JOB_NUMBER']
38
- spec.version = "#{spec.version}.ci.#{ENV['TRAVIS_JOB_NUMBER']}"
39
- end
35
+ version = Gitx::VERSION
36
+ version = "#{version}.ci.#{ENV['TRAVIS_JOB_NUMBER']}" if ENV['TRAVIS_JOB_NUMBER']
37
+ spec.version = version
40
38
  end
@@ -50,7 +50,7 @@ module Gitx
50
50
  end
51
51
 
52
52
  def config
53
- @configuration ||= Gitx::Configuration.new(repo.workdir)
53
+ @config ||= Gitx::Configuration.new(repo.workdir)
54
54
  end
55
55
 
56
56
  def executor
@@ -13,6 +13,7 @@ module Gitx
13
13
  method_option :message, type: :string, aliases: '-m', desc: 'message to attach to the buildtag'
14
14
  def buildtag
15
15
  raise "Branch must be one of the supported taggable branches: #{config.taggable_branches}" unless config.taggable_branch?(branch_name)
16
+
16
17
  run_git_cmd 'tag', build_tag, '--annotate', '--message', label
17
18
  run_git_cmd 'push', 'origin', build_tag
18
19
  end
@@ -28,7 +29,7 @@ module Gitx
28
29
  end
29
30
 
30
31
  def build_tag
31
- @buildtag ||= [
32
+ @build_tag ||= [
32
33
  BUILD_TAG_PREFIX,
33
34
  branch_name,
34
35
  utc_timestamp
@@ -38,6 +38,7 @@ module Gitx
38
38
  return false if config.reserved_branches.include?(branch)
39
39
  return false if config.aggregate_branch?(branch)
40
40
  return false if config.base_branch == branch
41
+
41
42
  true
42
43
  end
43
44
 
@@ -34,6 +34,7 @@ module Gitx
34
34
 
35
35
  def pull_request_for_branch(branch)
36
36
  return nil if config.reserved_branch?(branch)
37
+
37
38
  find_or_create_pull_request(branch)
38
39
  end
39
40
 
@@ -41,7 +42,7 @@ module Gitx
41
42
  fetch_remote_branch(integration_branch)
42
43
  begin
43
44
  run_git_cmd 'merge', '--no-ff', '--message', commit_message(branch, integration_branch, pull_request), branch
44
- rescue
45
+ rescue Gitx::Executor::ExecutionError
45
46
  raise MergeError, "Merge conflict occurred. Please fix merge conflict and rerun command with --resume #{branch} flag"
46
47
  end
47
48
  run_git_cmd 'push', 'origin', 'HEAD'
@@ -54,11 +55,9 @@ module Gitx
54
55
  end
55
56
 
56
57
  def feature_branch_name
57
- @feature_branch ||= begin
58
+ @feature_branch_name ||= begin
58
59
  feature_branch = options[:resume] || current_branch.name
59
- until local_branch_exists?(feature_branch)
60
- feature_branch = ask("#{feature_branch} does not exist. Please select one of the available local branches: #{local_branches}")
61
- end
60
+ feature_branch = ask("#{feature_branch} does not exist. Please select one of the available local branches: #{local_branches}") until local_branch_exists?(feature_branch)
62
61
  feature_branch
63
62
  end
64
63
  end
@@ -14,6 +14,7 @@ module Gitx
14
14
 
15
15
  last_known_good_tag = current_build_tag(good_branch)
16
16
  return unless yes?("Reset #{bad_branch} to #{last_known_good_tag}? (y/n)", :green)
17
+
17
18
  assert_aggregate_branch!(bad_branch)
18
19
  return if migrations_need_to_be_reverted?(bad_branch, last_known_good_tag)
19
20
 
@@ -34,6 +35,7 @@ module Gitx
34
35
 
35
36
  def migrations_need_to_be_reverted?(bad_branch, last_known_good_tag)
36
37
  return false unless File.exist?('db/migrate')
38
+
37
39
  outdated_migrations = run_git_cmd('diff', "#{last_known_good_tag}...#{bad_branch}", '--name-only', 'db/migrate').split
38
40
  return false if outdated_migrations.empty?
39
41
 
@@ -49,6 +51,7 @@ module Gitx
49
51
  def current_build_tag(branch)
50
52
  last_build_tag = build_tags_for_branch(branch).last
51
53
  raise "No known good tag found for branch: #{branch}. Verify tag exists via `git tag -l`" unless last_build_tag
54
+
52
55
  last_build_tag
53
56
  end
54
57
 
@@ -11,9 +11,10 @@ module Gitx
11
11
  desc 'release', 'release the current branch to production'
12
12
  method_option :cleanup, type: :boolean, desc: 'cleanup merged branches after release'
13
13
  def release(branch = nil)
14
- return unless yes?("Release #{current_branch.name} to #{config.base_branch}? (y/n)", :green)
15
-
16
14
  branch ||= current_branch.name
15
+
16
+ return unless yes?("Release #{branch} to #{config.base_branch}? (y/n)", :green)
17
+
17
18
  assert_not_protected_branch!(branch, 'release')
18
19
  checkout_branch(branch)
19
20
  run_git_cmd 'update'
@@ -21,10 +22,14 @@ module Gitx
21
22
  pull_request = find_or_create_pull_request(branch)
22
23
  return unless confirm_branch_status?(branch)
23
24
 
24
- checkout_branch config.base_branch
25
- run_git_cmd 'pull', 'origin', config.base_branch
26
- run_git_cmd 'merge', '--no-ff', '--message', commit_message(branch, pull_request), branch
27
- run_git_cmd 'push', 'origin', 'HEAD'
25
+ if (label = config.release_label)
26
+ label_pull_request pull_request, label
27
+ else
28
+ checkout_branch config.base_branch
29
+ run_git_cmd 'pull', 'origin', config.base_branch
30
+ run_git_cmd 'merge', '--no-ff', '--message', commit_message(branch, pull_request), branch
31
+ run_git_cmd 'push', 'origin', 'HEAD'
32
+ end
28
33
 
29
34
  after_release
30
35
  end
@@ -9,28 +9,28 @@ module Gitx
9
9
  include Gitx::Github
10
10
 
11
11
  BUMP_COMMENT_PREFIX = '[gitx] review bump :tada:'.freeze
12
- BUMP_COMMENT_FOOTER = <<-EOS.dedent
12
+ BUMP_COMMENT_FOOTER = <<-MESSAGE.dedent
13
13
  # Bump comments should include:
14
14
  # * Summary of what changed
15
15
  #
16
16
  # This footer will automatically be stripped from the created comment
17
- EOS
17
+ MESSAGE
18
18
  APPROVAL_COMMENT_PREFIX = '[gitx] review approved :shipit:'.freeze
19
- APPROVAL_COMMENT_FOOTER = <<-EOS.dedent
19
+ APPROVAL_COMMENT_FOOTER = <<-MESSAGE.dedent
20
20
  # Approval comments can include:
21
21
  # * Feedback
22
22
  # * Follow-up items for after release
23
23
  #
24
24
  # This footer will automatically be stripped from the created comment
25
- EOS
25
+ MESSAGE
26
26
  REJECTION_COMMENT_PREFIX = '[gitx] review rejected'.freeze
27
- REJECTION_COMMENT_FOOTER = <<-EOS.dedent
27
+ REJECTION_COMMENT_FOOTER = <<-MESSAGE.dedent
28
28
  # Rejection comments should include:
29
29
  # * Feedback
30
30
  # * Required changes before approved
31
31
  #
32
32
  # This footer will automatically be stripped from the created comment
33
- EOS
33
+ MESSAGE
34
34
 
35
35
  desc 'review', 'Create or update a pull request on github'
36
36
  method_option :title, type: :string, aliases: '-t', desc: 'pull request title'
@@ -6,14 +6,12 @@ module Gitx
6
6
  module Cli
7
7
  class StartCommand < BaseCommand
8
8
  EXAMPLE_BRANCH_NAMES = %w[api-fix-invalid-auth desktop-cleanup-avatar-markup share-form-add-edit-link].freeze
9
- VALID_BRANCH_NAME_REGEX = /^[A-Za-z0-9\-_]+$/
9
+ VALID_BRANCH_NAME_REGEX = /^[A-Za-z0-9\-_]+$/.freeze
10
10
 
11
11
  desc 'start', 'start a new git branch with latest changes from master'
12
- method_option :issue, type: :numeric, aliases: '-i', desc: 'Github issue number'
12
+ method_option :issue, type: :string, aliases: '-i', desc: 'Issue identifier'
13
13
  def start(branch_name = nil)
14
- until valid_new_branch_name?(branch_name)
15
- branch_name = ask("What would you like to name your branch? (ex: #{EXAMPLE_BRANCH_NAMES.sample})")
16
- end
14
+ branch_name = ask("What would you like to name your branch? (ex: #{EXAMPLE_BRANCH_NAMES.sample})") until valid_new_branch_name?(branch_name)
17
15
 
18
16
  checkout_branch config.base_branch
19
17
  run_git_cmd 'pull'
@@ -26,18 +24,22 @@ module Gitx
26
24
 
27
25
  def commit_message(branch_name)
28
26
  message = "[gitx] Start work on #{branch_name}"
29
- message += "\n\nConnected to ##{options[:issue]}" if options[:issue]
27
+ if (issue = options[:issue])
28
+ issue = issue.dup.prepend('#') if issue =~ /\A\d+\z/
29
+ message += "\n\nConnected to #{issue}"
30
+ end
30
31
  message
31
32
  end
32
33
 
33
34
  def valid_new_branch_name?(branch)
34
35
  return false if repo_branches.include?(branch)
36
+
35
37
  Rugged::Reference.valid_name?("refs/heads/#{branch}")
36
38
  end
37
39
 
38
40
  # get list of local and remote branches
39
41
  def repo_branches
40
- @branch_names ||= repo.branches.each_name.map do |branch|
42
+ @repo_branches ||= repo.branches.each_name.map do |branch|
41
43
  branch.gsub('origin/', '')
42
44
  end
43
45
  end
@@ -21,7 +21,7 @@ module Gitx
21
21
 
22
22
  def update_branch(branch)
23
23
  run_git_cmd 'pull', 'origin', branch
24
- rescue
24
+ rescue Gitx::Executor::ExecutionError
25
25
  raise MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command'
26
26
  end
27
27
 
@@ -17,6 +17,10 @@ module Gitx
17
17
  config[:base_branch]
18
18
  end
19
19
 
20
+ def release_label
21
+ config[:release_label]
22
+ end
23
+
20
24
  def aggregate_branches
21
25
  config[:aggregate_branches]
22
26
  end
@@ -2,6 +2,10 @@
2
2
  # default base branch
3
3
  base_branch: master
4
4
 
5
+ # Label to use for releasing a pull request, if this is set a label will be
6
+ # added to the PR rather than merging to the base branch
7
+ release_label:
8
+
5
9
  # list of branches eligable for integration
6
10
  aggregate_branches:
7
11
  - staging
data/lib/gitx/executor.rb CHANGED
@@ -15,6 +15,7 @@ module Gitx
15
15
  loop do
16
16
  line = stdout_err.gets
17
17
  break unless line
18
+
18
19
  output << line
19
20
  yield line if block_given?
20
21
  end
data/lib/gitx/github.rb CHANGED
@@ -7,7 +7,7 @@ module Gitx
7
7
  GLOBAL_CONFIG_FILE = '~/.config/gitx/github.yml'.freeze
8
8
  REVIEW_CONTEXT = 'peer_review'.freeze
9
9
  CLIENT_URL = 'https://github.com/wireframe/gitx'.freeze
10
- PULL_REQUEST_FOOTER = <<-EOS.dedent
10
+ PULL_REQUEST_FOOTER = <<-MESSAGE.dedent
11
11
  # Pull Request Protips(tm):
12
12
  # * Describe how this change accomplishes the task at hand
13
13
  # * Use GitHub flavored Markdown http://github.github.com/github-flavored-markdown/
@@ -16,7 +16,7 @@ module Gitx
16
16
  # * Review CONTRIBUTING.md for relevant workflow requirements
17
17
  #
18
18
  # This footer will automatically be stripped from the pull request description
19
- EOS
19
+ MESSAGE
20
20
 
21
21
  def find_or_create_pull_request(branch)
22
22
  pull_request = find_pull_request(branch)
@@ -57,6 +57,10 @@ module Gitx
57
57
  github_client.create_status(github_slug, commit_sha, state, context: REVIEW_CONTEXT, description: description)
58
58
  end
59
59
 
60
+ def label_pull_request(pull_request, label)
61
+ github_client.add_labels_to_an_issue(github_slug, pull_request.number, [label])
62
+ end
63
+
60
64
  # @see http://developer.github.com/v3/pulls/
61
65
  def create_pull_request(branch)
62
66
  say 'Creating pull request for '
@@ -124,7 +128,7 @@ module Gitx
124
128
  end
125
129
 
126
130
  def github_client
127
- @client ||= Octokit::Client.new(access_token: authorization_token)
131
+ @github_client ||= Octokit::Client.new(access_token: authorization_token)
128
132
  end
129
133
 
130
134
  # @return [String] github username (ex: 'wireframe') of the current github.user
@@ -132,6 +136,7 @@ module Gitx
132
136
  def username
133
137
  username = repo.config['github.user']
134
138
  raise "Github user not configured. Run: `git config --global github.user 'me@email.com'`" unless username
139
+
135
140
  username
136
141
  end
137
142
 
@@ -142,7 +147,7 @@ module Gitx
142
147
  # https://github.com/wireframe/gitx.git #=> wireframe/gitx
143
148
  def github_slug
144
149
  remote = repo.config['remote.origin.url']
145
- remote.to_s.gsub(/\.git$/, '').split(%r{[:\/]}).last(2).join('/')
150
+ remote.to_s.gsub(/\.git$/, '').split(%r{[:/]}).last(2).join('/')
146
151
  end
147
152
 
148
153
  def github_organization
@@ -154,9 +159,7 @@ module Gitx
154
159
  end
155
160
 
156
161
  def global_config
157
- @config ||= begin
158
- File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
159
- end
162
+ @global_config ||= File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
160
163
  end
161
164
 
162
165
  def save_global_config(options)
data/lib/gitx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gitx
2
- VERSION = '3.0.2'.freeze
2
+ VERSION = '3.2.0'.freeze
3
3
  end
@@ -145,5 +145,6 @@ http_interactions:
145
145
  encoding: UTF-8
146
146
  string: '{"state":"success"}'
147
147
  http_version:
148
- recorded_at: Wed, 10 Dec 2014 19:14:11 GMT
148
+ recorded_at: Tue, 05 Aug 2014 16:36:03 GMT
149
149
  recorded_with: VCR 2.9.2
150
+
@@ -0,0 +1,228 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.github.com/repos/wireframe/gitx/pulls?head=wireframe:feature-branch&state=open
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/vnd.github.v3+json
12
+ User-Agent:
13
+ - Octokit Ruby Gem 3.2.0
14
+ Authorization:
15
+ - token 123123
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - GitHub.com
25
+ Date:
26
+ - Tue, 05 Aug 2014 16:36:03 GMT
27
+ Content-Type:
28
+ - application/json; charset=utf-8
29
+ Status:
30
+ - 200 OK
31
+ X-Ratelimit-Limit:
32
+ - '5000'
33
+ X-Ratelimit-Remaining:
34
+ - '4991'
35
+ X-Ratelimit-Reset:
36
+ - '1407257585'
37
+ Cache-Control:
38
+ - private, max-age=60, s-maxage=60
39
+ Etag:
40
+ - '"6d00d48abf2adf1877c8244700cd4c6f"'
41
+ X-Oauth-Scopes:
42
+ - repo
43
+ X-Accepted-Oauth-Scopes:
44
+ - ''
45
+ Vary:
46
+ - Accept, Authorization, Cookie, X-GitHub-OTP
47
+ - Accept-Encoding
48
+ X-Github-Media-Type:
49
+ - github.v3; format=json
50
+ Link:
51
+ - <https://api.github.com/repositories/17608725/pulls?head=wireframe%3Afeature-branch&state=open&page=0>;
52
+ rel="last"
53
+ X-Xss-Protection:
54
+ - 1; mode=block
55
+ X-Frame-Options:
56
+ - deny
57
+ Content-Security-Policy:
58
+ - default-src 'none'
59
+ Content-Length:
60
+ - '2'
61
+ Access-Control-Allow-Credentials:
62
+ - 'true'
63
+ Access-Control-Expose-Headers:
64
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
65
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
66
+ Access-Control-Allow-Origin:
67
+ - "*"
68
+ X-Github-Request-Id:
69
+ - 46C5E25C:1E4F:1642AD9:53E107F3
70
+ Strict-Transport-Security:
71
+ - max-age=31536000; includeSubdomains
72
+ X-Content-Type-Options:
73
+ - nosniff
74
+ X-Served-By:
75
+ - d818ddef80f4c7d10683dd483558952a
76
+ body:
77
+ encoding: UTF-8
78
+ string: '[{"html_url":"https://path/to/html/pull/request","issue_url":"https://api/path/to/issue/url","number":10,"head":{"ref":"branch_name", "sha": "e12da4"}}]'
79
+ http_version:
80
+ recorded_at: Tue, 05 Aug 2014 16:36:03 GMT
81
+ - request:
82
+ method: get
83
+ uri: https://api.github.com/repos/wireframe/gitx/commits/feature-branch/status
84
+ body:
85
+ encoding: US-ASCII
86
+ string: ''
87
+ headers:
88
+ Accept:
89
+ - application/vnd.github.v3+json
90
+ User-Agent:
91
+ - Octokit Ruby Gem 3.4.0
92
+ Content-Type:
93
+ - application/json
94
+ Authorization:
95
+ - token 123123
96
+ Accept-Encoding:
97
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
98
+ response:
99
+ status:
100
+ code: 200
101
+ message: OK
102
+ headers:
103
+ Server:
104
+ - GitHub.com
105
+ Date:
106
+ - Wed, 10 Dec 2014 19:01:27 GMT
107
+ Content-Type:
108
+ - application/json; charset=utf-8
109
+ Transfer-Encoding:
110
+ - chunked
111
+ Status:
112
+ - 200 OK
113
+ X-Ratelimit-Limit:
114
+ - '5000'
115
+ X-Ratelimit-Remaining:
116
+ - '4993'
117
+ X-Ratelimit-Reset:
118
+ - '1418241620'
119
+ X-Oauth-Scopes:
120
+ - repo
121
+ X-Accepted-Oauth-Scopes:
122
+ - repo, repo:status
123
+ X-Github-Media-Type:
124
+ - github.v3; format=json
125
+ X-Xss-Protection:
126
+ - 1; mode=block
127
+ X-Frame-Options:
128
+ - deny
129
+ Content-Security-Policy:
130
+ - default-src 'none'
131
+ Access-Control-Allow-Credentials:
132
+ - 'true'
133
+ Access-Control-Expose-Headers:
134
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
135
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
136
+ Access-Control-Allow-Origin:
137
+ - "*"
138
+ X-Github-Request-Id:
139
+ - C6CBAFAF:141D:2F27072:54889887
140
+ Strict-Transport-Security:
141
+ - max-age=31536000; includeSubdomains; preload
142
+ X-Content-Type-Options:
143
+ - nosniff
144
+ body:
145
+ encoding: UTF-8
146
+ string: '{"state":"success"}'
147
+ http_version:
148
+ recorded_at: Tue, 05 Aug 2014 16:36:03 GMT
149
+ - request:
150
+ method: post
151
+ uri: https://api.github.com/repos/wireframe/gitx/issues/10/labels
152
+ body:
153
+ encoding: US-ASCII
154
+ string: ''
155
+ headers:
156
+ Accept:
157
+ - application/vnd.github.v3+json
158
+ User-Agent:
159
+ - Octokit Ruby Gem 3.2.0
160
+ Authorization:
161
+ - token 123123
162
+ Accept-Encoding:
163
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
164
+ response:
165
+ status:
166
+ code: 200
167
+ message: OK
168
+ headers:
169
+ Server:
170
+ - GitHub.com
171
+ Date:
172
+ - Tue, 05 Aug 2014 16:36:03 GMT
173
+ Content-Type:
174
+ - application/json; charset=utf-8
175
+ Status:
176
+ - 200 OK
177
+ X-Ratelimit-Limit:
178
+ - '5000'
179
+ X-Ratelimit-Remaining:
180
+ - '4991'
181
+ X-Ratelimit-Reset:
182
+ - '1407257585'
183
+ Cache-Control:
184
+ - private, max-age=60, s-maxage=60
185
+ Etag:
186
+ - '"6d00d48abf2adf1877c8244700cd4c6f"'
187
+ X-Oauth-Scopes:
188
+ - repo
189
+ X-Accepted-Oauth-Scopes:
190
+ - ''
191
+ Vary:
192
+ - Accept, Authorization, Cookie, X-GitHub-OTP
193
+ - Accept-Encoding
194
+ X-Github-Media-Type:
195
+ - github.v3; format=json
196
+ Link:
197
+ - <https://api.github.com/repositories/17608725/pulls?head=wireframe%3Afeature-branch&state=open&page=0>;
198
+ rel="last"
199
+ X-Xss-Protection:
200
+ - 1; mode=block
201
+ X-Frame-Options:
202
+ - deny
203
+ Content-Security-Policy:
204
+ - default-src 'none'
205
+ Content-Length:
206
+ - '2'
207
+ Access-Control-Allow-Credentials:
208
+ - 'true'
209
+ Access-Control-Expose-Headers:
210
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
211
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
212
+ Access-Control-Allow-Origin:
213
+ - "*"
214
+ X-Github-Request-Id:
215
+ - 46C5E25C:1E4F:1642AD9:53E107F3
216
+ Strict-Transport-Security:
217
+ - max-age=31536000; includeSubdomains
218
+ X-Content-Type-Options:
219
+ - nosniff
220
+ X-Served-By:
221
+ - d818ddef80f4c7d10683dd483558952a
222
+ body:
223
+ encoding: UTF-8
224
+ string: '[{"id":1,"name":"release-me"}]'
225
+ http_version:
226
+ recorded_at: Tue, 05 Aug 2014 16:36:03 GMT
227
+ recorded_with: VCR 2.9.2
228
+
@@ -19,6 +19,7 @@ describe Gitx::Cli::IntegrateCommand do
19
19
 
20
20
  before do
21
21
  allow(cli).to receive(:current_branch).and_return(current_branch)
22
+ allow(cli).to receive(:github_slug).and_return('wireframe/gitx')
22
23
  branches = double('fake branches')
23
24
  allow(branches).to receive(:each_name).with(:local).and_return(local_branch_names)
24
25
  allow(branches).to receive(:each_name).with(:remote).and_return(remote_branch_names)
@@ -159,10 +160,10 @@ describe Gitx::Cli::IntegrateCommand do
159
160
  expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
160
161
  expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
161
162
  expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Integrate feature-branch into staging\n\nConnected to #10", 'feature-branch')
162
- .and_raise('git merge feature-branch failed').ordered
163
+ .and_raise(Gitx::Executor::ExecutionError).ordered
163
164
 
164
165
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
165
- expect { cli.integrate }.to raise_error(/Merge conflict occurred. Please fix merge conflict and rerun command with --resume feature-branch flag/)
166
+ expect { cli.integrate }.to raise_error(Gitx::Cli::BaseCommand::MergeError, /Merge conflict occurred. Please fix merge conflict and rerun command with --resume feature-branch flag/)
166
167
  end
167
168
  end
168
169
  it 'raises a helpful error' do
@@ -17,6 +17,7 @@ describe Gitx::Cli::ReleaseCommand do
17
17
 
18
18
  before do
19
19
  allow(cli).to receive(:current_branch).and_return(branch)
20
+ allow(cli).to receive(:github_slug).and_return('wireframe/gitx')
20
21
  end
21
22
 
22
23
  describe '#release' do
@@ -58,6 +59,7 @@ describe Gitx::Cli::ReleaseCommand do
58
59
  expect(repo).to receive(:workdir).and_return(temp_dir)
59
60
 
60
61
  expect(cli).to receive(:yes?).and_return(true)
62
+ expect(cli).to_not receive(:label_pull_request)
61
63
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
62
64
 
63
65
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
@@ -200,5 +202,38 @@ describe Gitx::Cli::ReleaseCommand do
200
202
  should meet_expectations
201
203
  end
202
204
  end
205
+ context 'when user confirms release and pull request exists with success status with release_label config' do
206
+ let(:gitx_config) do
207
+ {
208
+ 'release_label' => 'release-me'
209
+ }
210
+ end
211
+ before do
212
+ expect(repo).to receive(:workdir).and_return(temp_dir)
213
+ File.open(File.join(temp_dir, '.gitx.yml'), 'w') do |f|
214
+ f.puts gitx_config.to_yaml
215
+ end
216
+
217
+ expect(cli).to receive(:yes?).and_return(true)
218
+ expect(cli).to receive(:label_pull_request).with(having_attributes(number: 10), 'release-me').and_call_original
219
+ allow(cli).to receive(:authorization_token).and_return(authorization_token)
220
+
221
+ expect(executor).to_not receive(:execute).with('git', 'checkout', 'master')
222
+ expect(executor).to_not receive(:execute).with('git', 'pull', 'origin', 'master')
223
+ expect(executor).to_not receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to master\n\nConnected to #10", 'feature-branch')
224
+ expect(executor).to_not receive(:execute).with('git', 'push', 'origin', 'HEAD')
225
+
226
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
227
+ expect(executor).to receive(:execute).with('git', 'update').ordered
228
+ expect(executor).to receive(:execute).with('git integrate').ordered
229
+
230
+ VCR.use_cassette('pull_request_does_exist_with_success_status_and_then_add_label') do
231
+ cli.release
232
+ end
233
+ end
234
+ it 'runs expected commands' do
235
+ should meet_expectations
236
+ end
237
+ end
203
238
  end
204
239
  end
@@ -112,10 +112,10 @@ describe Gitx::Cli::StartCommand do
112
112
  should meet_expectations
113
113
  end
114
114
  end
115
- context 'when --issue option is used' do
115
+ context 'when --issue option is used with a numeric issue ID' do
116
116
  let(:options) do
117
117
  {
118
- issue: 10
118
+ issue: '10'
119
119
  }
120
120
  end
121
121
  before do
@@ -131,5 +131,24 @@ describe Gitx::Cli::StartCommand do
131
131
  should meet_expectations
132
132
  end
133
133
  end
134
+ context 'when --issue option is used with a non-numeric issue ID' do
135
+ let(:options) do
136
+ {
137
+ issue: 'FOO-123'
138
+ }
139
+ end
140
+ before do
141
+ expect(cli).to receive(:checkout_branch).with('master').ordered
142
+ expect(executor).to receive(:execute).with('git', 'pull').ordered
143
+ expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
144
+ expect(cli).to receive(:checkout_branch).with('new-branch').ordered
145
+ expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', "[gitx] Start work on new-branch\n\nConnected to FOO-123").ordered
146
+
147
+ cli.start 'new-branch'
148
+ end
149
+ it 'creates empty commit with link to issue id' do
150
+ should meet_expectations
151
+ end
152
+ end
134
153
  end
135
154
  end
@@ -41,7 +41,7 @@ describe Gitx::Cli::UpdateCommand do
41
41
  before do
42
42
  allow(cli).to receive(:say)
43
43
 
44
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').and_raise('merge error').ordered
44
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').and_raise(Gitx::Executor::ExecutionError).ordered
45
45
 
46
46
  expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command')
47
47
  end
@@ -54,7 +54,7 @@ describe Gitx::Cli::UpdateCommand do
54
54
  allow(cli).to receive(:say)
55
55
 
56
56
  expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').ordered
57
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').and_raise('merge error occurred').ordered
57
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').and_raise(Gitx::Executor::ExecutionError).ordered
58
58
 
59
59
  expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command')
60
60
  end
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,7 @@ require 'bundler/setup'
8
8
 
9
9
  # Requires supporting ruby files with custom matchers and macros, etc,
10
10
  # in spec/support/ and its subdirectories.
11
- Dir[File.join(__dir__, 'support/**/*.rb')].each { |f| require f }
11
+ Dir[File.join(__dir__, 'support/**/*.rb')].sort.each { |f| require f }
12
12
 
13
13
  # This file was generated by the `rspec --init` command. Conventionally, all
14
14
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
metadata CHANGED
@@ -1,45 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitx
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.2
4
+ version: 3.2.0.ci.231.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Sonnek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-25 00:00:00.000000000 Z
11
+ date: 2021-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rugged
14
+ name: octokit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.26.0
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.26.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: thor
28
+ name: rugged
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.27.10
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.27.10
41
41
  - !ruby/object:Gem::Dependency
42
- name: octokit
42
+ name: thor
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rake
70
+ name: coveralls
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,21 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '3.0'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '3.0'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: pry
98
+ name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,21 +109,21 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: webmock
112
+ name: rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '3.0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '3.0'
125
125
  - !ruby/object:Gem::Dependency
126
- name: timecop
126
+ name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
@@ -137,7 +137,7 @@ dependencies:
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
- name: vcr
140
+ name: timecop
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - ">="
@@ -151,7 +151,7 @@ dependencies:
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
- name: coveralls
154
+ name: vcr
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
@@ -165,7 +165,7 @@ dependencies:
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
- name: rubocop
168
+ name: webmock
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
171
  - - ">="
@@ -240,6 +240,7 @@ files:
240
240
  - lib/gitx/version.rb
241
241
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_failure_status.yml
242
242
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status.yml
243
+ - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status_and_then_add_label.yml
243
244
  - spec/fixtures/vcr_cassettes/pull_request_does_not_exist.yml
244
245
  - spec/gitx/cli/base_command_spec.rb
245
246
  - spec/gitx/cli/buildtag_command_spec.rb
@@ -274,21 +275,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
274
275
  requirements:
275
276
  - - ">="
276
277
  - !ruby/object:Gem::Version
277
- version: '0'
278
+ version: 2.6.7
278
279
  required_rubygems_version: !ruby/object:Gem::Requirement
279
280
  requirements:
280
- - - ">="
281
+ - - ">"
281
282
  - !ruby/object:Gem::Version
282
- version: '0'
283
+ version: 1.3.1
283
284
  requirements: []
284
- rubyforge_project:
285
- rubygems_version: 2.6.6
285
+ rubygems_version: 3.0.8
286
286
  signing_key:
287
287
  specification_version: 4
288
288
  summary: Utility scripts for Git to increase productivity for common operations
289
289
  test_files:
290
290
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_failure_status.yml
291
291
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status.yml
292
+ - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status_and_then_add_label.yml
292
293
  - spec/fixtures/vcr_cassettes/pull_request_does_not_exist.yml
293
294
  - spec/gitx/cli/base_command_spec.rb
294
295
  - spec/gitx/cli/buildtag_command_spec.rb