gitx 3.1.2 → 4.1.0

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
2
  SHA256:
3
- metadata.gz: 7e08878dfac9d91e18971c1f5a1004514d00a3166c097150ee4bb4b7facdcd71
4
- data.tar.gz: f0e9e7588b0055cad2cdaca6e3daabc6130f1edc6a59aaf7ee77b8445eb20646
3
+ metadata.gz: 59f45788834b6e13ec3fd859fe45cde1d4f84f1205866f0b72dd6800d40b6e5d
4
+ data.tar.gz: a08cd9beca1c16bc02f5654ed056e7e93d89e21df5914cb7507c04d679b6f1ec
5
5
  SHA512:
6
- metadata.gz: cf60c209410079bcdb1fa2af67fb84a6c60976de3f18fa6cc8d13bd4a95db2f698e03843d991611a82facfcbe1a2957a85bf4628992794fd3193925cb0edb8f5
7
- data.tar.gz: 7e0327e79b99e1c7eb1e40d21aca02881cb73f5d4b465c5b29b3d14bda905551b8d515322f26d516685bad62564b94055c7221bfc078d4c66f88c3049ab618f2
6
+ metadata.gz: 8d464966f06a39cadd33a9830130c5f25edbed7eccba994ce96fee827a1f8e9cdaa75dd4c3553338774b15fb5de2ce5185882034e506c6057b6d1a12f92b67d9
7
+ data.tar.gz: ac922c59dae45ed1d87c5e86c719628e2dfc55d13daffb9b9891cc01ced3672573c2916dbb6b9290fe8ae6ef5fe846322d71e574bf7c092bf39c32f249c35a22
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.6.6
1
+ 2.7.3
data/CONTRIBUTING.md CHANGED
@@ -25,7 +25,7 @@ Use [Test Driven Development](http://en.wikipedia.org/wiki/Test-driven_developme
25
25
  * Follow [best practices](http://robots.thoughtbot.com/post/48933156625/5-useful-tips-for-a-better-commit-message) for git commit messages to communicate your changes.
26
26
  * Add [ticket references to commits to automatically trigger product management workflows](http://help.sprint.ly/knowledgebase/articles/108139-available-scm-vcs-commands)
27
27
  * Only write the **minimal** amount of code necessary to accomplish the given task.
28
- * Ensure branch stays up-to-date with latest changes that are merged into master by using: `$ git update`
28
+ * Ensure branch stays up-to-date with latest changes that are merged into main by using: `$ git update`
29
29
  * Changes that are not directly related to the current feature should be cherry-picked into their own branch and merged separately.
30
30
 
31
31
  ### Testing Protips™
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Build Status](https://travis-ci.org/wireframe/gitx.png?branch=master)](https://travis-ci.org/wireframe/gitx)
1
+ [![Build Status](https://travis-ci.org/wireframe/gitx.png?branch=main)](https://travis-ci.org/wireframe/gitx)
2
2
  [![Code Coverage](https://coveralls.io/repos/wireframe/gitx/badge.png)](https://coveralls.io/r/wireframe/gitx)
3
3
  [![Code Climate](https://codeclimate.com/github/wireframe/gitx.png)](https://codeclimate.com/github/wireframe/gitx)
4
4
 
@@ -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, main). 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
@@ -3,18 +3,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
  require 'gitx/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
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'
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'
13
14
 
14
- spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
- 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']
18
19
 
19
20
  spec.add_runtime_dependency 'octokit'
20
21
  spec.add_runtime_dependency 'rugged', '~> 0.27.10'
@@ -5,7 +5,7 @@ require 'gitx/cli/base_command'
5
5
  module Gitx
6
6
  module Cli
7
7
  class CleanupCommand < BaseCommand
8
- desc 'cleanup', 'Cleanup branches that have been merged into master from the repo'
8
+ desc 'cleanup', 'Cleanup branches that have been merged into main from the repo'
9
9
  def cleanup
10
10
  update_base_branch
11
11
  say 'Deleting local and remote branches that have been merged into '
@@ -9,6 +9,7 @@ module Gitx
9
9
  class IntegrateCommand < BaseCommand
10
10
  include Gitx::Github
11
11
  desc 'integrate', 'integrate the current branch into one of the aggregate development branches (default = staging)'
12
+ method_option :'skip-pull-request', type: :boolean, desc: 'skip pull request reference in merge commit'
12
13
  method_option :resume, type: :string, aliases: '-r', desc: 'resume merging of feature-branch'
13
14
  def integrate(integration_branch = 'staging')
14
15
  assert_aggregate_branch!(integration_branch)
@@ -17,7 +18,7 @@ module Gitx
17
18
  print_message(branch, integration_branch)
18
19
 
19
20
  run_git_cmd 'update'
20
- pull_request = pull_request_for_branch(branch)
21
+ pull_request = pull_request_for_branch(branch) unless options[:'skip-pull-request']
21
22
  integrate_branch(branch, integration_branch, pull_request) unless options[:resume]
22
23
  checkout_branch branch
23
24
  end
@@ -12,7 +12,7 @@ module Gitx
12
12
  method_option :cleanup, type: :boolean, desc: 'cleanup merged branches after release'
13
13
  def release(branch = nil)
14
14
  branch ||= current_branch.name
15
-
15
+
16
16
  return unless yes?("Release #{branch} to #{config.base_branch}? (y/n)", :green)
17
17
 
18
18
  assert_not_protected_branch!(branch, 'release')
@@ -20,12 +20,16 @@ module Gitx
20
20
  run_git_cmd 'update'
21
21
 
22
22
  pull_request = find_or_create_pull_request(branch)
23
- return unless confirm_branch_status?(branch)
24
23
 
25
- checkout_branch config.base_branch
26
- run_git_cmd 'pull', 'origin', config.base_branch
27
- run_git_cmd 'merge', '--no-ff', '--message', commit_message(branch, pull_request), branch
28
- run_git_cmd 'push', 'origin', 'HEAD'
24
+ if (label = config.release_label)
25
+ label_pull_request pull_request, label
26
+ else
27
+ return unless confirm_branch_status?(branch)
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
29
33
 
30
34
  after_release
31
35
  end
@@ -8,7 +8,7 @@ module Gitx
8
8
  EXAMPLE_BRANCH_NAMES = %w[api-fix-invalid-auth desktop-cleanup-avatar-markup share-form-add-edit-link].freeze
9
9
  VALID_BRANCH_NAME_REGEX = /^[A-Za-z0-9\-_]+$/.freeze
10
10
 
11
- desc 'start', 'start a new git branch with latest changes from master'
11
+ desc 'start', 'start a new git branch with latest changes from main'
12
12
  method_option :issue, type: :string, aliases: '-i', desc: 'Issue identifier'
13
13
  def start(branch_name = nil)
14
14
  branch_name = ask("What would you like to name your branch? (ex: #{EXAMPLE_BRANCH_NAMES.sample})") until valid_new_branch_name?(branch_name)
@@ -5,22 +5,31 @@ require 'gitx/cli/base_command'
5
5
  module Gitx
6
6
  module Cli
7
7
  class UpdateCommand < BaseCommand
8
- desc 'update', 'Update the current branch with latest changes from the remote feature branch and master'
8
+ desc 'update', 'Update the current branch with latest changes from the remote feature branch and main'
9
9
  def update
10
10
  say 'Updating '
11
11
  say "#{current_branch.name} ", :green
12
12
  say 'with latest changes from '
13
13
  say config.base_branch, :green
14
14
 
15
+ update_base_branch
15
16
  update_branch(current_branch.name) if remote_branch_exists?(current_branch.name)
16
- update_branch(config.base_branch)
17
+ update_branch(config.base_branch, repository: '.')
18
+
17
19
  run_git_cmd 'share'
18
20
  end
19
21
 
20
22
  private
21
23
 
22
- def update_branch(branch)
23
- run_git_cmd 'pull', 'origin', branch
24
+ def update_base_branch
25
+ branch_name = current_branch.name
26
+ checkout_branch(config.base_branch)
27
+ update_branch(config.base_branch)
28
+ checkout_branch(branch_name)
29
+ end
30
+
31
+ def update_branch(branch, repository: 'origin')
32
+ run_git_cmd 'pull', repository, branch
24
33
  rescue Gitx::Executor::ExecutionError
25
34
  raise MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command'
26
35
  end
@@ -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
@@ -1,6 +1,10 @@
1
1
  ---
2
2
  # default base branch
3
- base_branch: master
3
+ base_branch: main
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:
4
8
 
5
9
  # list of branches eligable for integration
6
10
  aggregate_branches:
@@ -10,16 +14,16 @@ aggregate_branches:
10
14
  # list of branches that should not be deleted when cleaning up
11
15
  reserved_branches:
12
16
  - HEAD
13
- - master
17
+ - main
14
18
  - next_release
15
19
  - staging
16
20
  - prototype
17
21
 
18
22
  # list of supported branches for generating buildtags
19
23
  taggable_branches:
20
- - master
24
+ - main
21
25
  - staging
22
26
 
23
27
  # list of commands to execute after releasing feature branch
24
28
  after_release:
25
- - git integrate
29
+ - git integrate --skip-pull-request
data/lib/gitx/github.rb CHANGED
@@ -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 '
@@ -143,7 +147,7 @@ module Gitx
143
147
  # https://github.com/wireframe/gitx.git #=> wireframe/gitx
144
148
  def github_slug
145
149
  remote = repo.config['remote.origin.url']
146
- remote.to_s.gsub(/\.git$/, '').split(%r{[:\/]}).last(2).join('/')
150
+ remote.to_s.gsub(/\.git$/, '').split(%r{[:/]}).last(2).join('/')
147
151
  end
148
152
 
149
153
  def github_organization
@@ -155,9 +159,7 @@ module Gitx
155
159
  end
156
160
 
157
161
  def global_config
158
- @global_config ||= begin
159
- File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
160
- end
162
+ @global_config ||= File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
161
163
  end
162
164
 
163
165
  def save_global_config(options)
data/lib/gitx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gitx
2
- VERSION = '3.1.2'.freeze
2
+ VERSION = '4.1.0'.freeze
3
3
  end
@@ -0,0 +1,160 @@
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: post
83
+ uri: https://api.github.com/repos/wireframe/gitx/issues/10/labels
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.2.0
92
+ Authorization:
93
+ - token 123123
94
+ Accept-Encoding:
95
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
96
+ response:
97
+ status:
98
+ code: 200
99
+ message: OK
100
+ headers:
101
+ Server:
102
+ - GitHub.com
103
+ Date:
104
+ - Tue, 05 Aug 2014 16:36:03 GMT
105
+ Content-Type:
106
+ - application/json; charset=utf-8
107
+ Status:
108
+ - 200 OK
109
+ X-Ratelimit-Limit:
110
+ - '5000'
111
+ X-Ratelimit-Remaining:
112
+ - '4991'
113
+ X-Ratelimit-Reset:
114
+ - '1407257585'
115
+ Cache-Control:
116
+ - private, max-age=60, s-maxage=60
117
+ Etag:
118
+ - '"6d00d48abf2adf1877c8244700cd4c6f"'
119
+ X-Oauth-Scopes:
120
+ - repo
121
+ X-Accepted-Oauth-Scopes:
122
+ - ''
123
+ Vary:
124
+ - Accept, Authorization, Cookie, X-GitHub-OTP
125
+ - Accept-Encoding
126
+ X-Github-Media-Type:
127
+ - github.v3; format=json
128
+ Link:
129
+ - <https://api.github.com/repositories/17608725/pulls?head=wireframe%3Afeature-branch&state=open&page=0>;
130
+ rel="last"
131
+ X-Xss-Protection:
132
+ - 1; mode=block
133
+ X-Frame-Options:
134
+ - deny
135
+ Content-Security-Policy:
136
+ - default-src 'none'
137
+ Content-Length:
138
+ - '2'
139
+ Access-Control-Allow-Credentials:
140
+ - 'true'
141
+ Access-Control-Expose-Headers:
142
+ - ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset,
143
+ X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
144
+ Access-Control-Allow-Origin:
145
+ - "*"
146
+ X-Github-Request-Id:
147
+ - 46C5E25C:1E4F:1642AD9:53E107F3
148
+ Strict-Transport-Security:
149
+ - max-age=31536000; includeSubdomains
150
+ X-Content-Type-Options:
151
+ - nosniff
152
+ X-Served-By:
153
+ - d818ddef80f4c7d10683dd483558952a
154
+ body:
155
+ encoding: UTF-8
156
+ string: '[{"id":1,"name":"release-me"}]'
157
+ http_version:
158
+ recorded_at: Tue, 05 Aug 2014 16:36:03 GMT
159
+ recorded_with: VCR 2.9.2
160
+
@@ -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
+
@@ -23,7 +23,7 @@ describe Gitx::Cli::BuildtagCommand do
23
23
  expect { cli.buildtag }.to raise_error(/Branch must be one of the supported taggable branches/)
24
24
  end
25
25
  end
26
- context 'when options[:branch] is NOT master or staging' do
26
+ context 'when options[:branch] is NOT main or staging' do
27
27
  let(:options) do
28
28
  {
29
29
  branch: 'feature-branch'
@@ -33,16 +33,16 @@ describe Gitx::Cli::BuildtagCommand do
33
33
  expect { cli.buildtag }.to raise_error(/Branch must be one of the supported taggable branches/)
34
34
  end
35
35
  end
36
- context 'when options[:branch] is master' do
36
+ context 'when options[:branch] is main' do
37
37
  let(:options) do
38
38
  {
39
- branch: 'master'
39
+ branch: 'main'
40
40
  }
41
41
  end
42
42
  before do
43
43
  Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
44
- expect(executor).to receive(:execute).with('git', 'tag', 'builds/master/2013-10-30-10-21-28', '--annotate', '--message', '[gitx] buildtag for master').ordered
45
- expect(executor).to receive(:execute).with('git', 'push', 'origin', 'builds/master/2013-10-30-10-21-28').ordered
44
+ expect(executor).to receive(:execute).with('git', 'tag', 'builds/main/2013-10-30-10-21-28', '--annotate', '--message', '[gitx] buildtag for main').ordered
45
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'builds/main/2013-10-30-10-21-28').ordered
46
46
  cli.buildtag
47
47
  end
48
48
  end
@@ -53,14 +53,14 @@ describe Gitx::Cli::BuildtagCommand do
53
53
  context 'when options[:message] is passed' do
54
54
  let(:options) do
55
55
  {
56
- branch: 'master',
56
+ branch: 'main',
57
57
  message: 'custom git commit message'
58
58
  }
59
59
  end
60
60
  before do
61
61
  Timecop.freeze(Time.utc(2013, 10, 30, 10, 21, 28)) do
62
- expect(executor).to receive(:execute).with('git', 'tag', 'builds/master/2013-10-30-10-21-28', '--annotate', '--message', 'custom git commit message').ordered
63
- expect(executor).to receive(:execute).with('git', 'push', 'origin', 'builds/master/2013-10-30-10-21-28').ordered
62
+ expect(executor).to receive(:execute).with('git', 'tag', 'builds/main/2013-10-30-10-21-28', '--annotate', '--message', 'custom git commit message').ordered
63
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'builds/main/2013-10-30-10-21-28').ordered
64
64
  cli.buildtag
65
65
  end
66
66
  end
@@ -38,7 +38,7 @@ describe Gitx::Cli::CleanupCommand do
38
38
  before do
39
39
  allow(cli).to receive(:say)
40
40
 
41
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
41
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
42
42
  expect(executor).to receive(:execute).with('git', 'pull').ordered
43
43
  expect(executor).to receive(:execute).with('git', 'remote', 'prune', 'origin').ordered
44
44
  expect(executor).to receive(:execute).with('git', 'branch', '--delete', 'merged-local-feature').ordered
@@ -58,7 +58,7 @@ describe Gitx::Cli::CleanupCommand do
58
58
  before do
59
59
  allow(cli).to receive(:say)
60
60
 
61
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
61
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
62
62
  expect(executor).to receive(:execute).with('git', 'pull').ordered
63
63
  expect(executor).to receive(:execute).with('git', 'remote', 'prune', 'origin').ordered
64
64
  expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'merged-remote-feature').ordered
@@ -78,7 +78,7 @@ describe Gitx::Cli::CleanupCommand do
78
78
  before do
79
79
  allow(cli).to receive(:say)
80
80
 
81
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
81
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
82
82
  expect(executor).to receive(:execute).with('git', 'pull').ordered
83
83
  expect(executor).to receive(:execute).with('git', 'remote', 'prune', 'origin').ordered
84
84
  expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'merged-remote-feature/review').ordered
@@ -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)
@@ -46,18 +47,18 @@ describe Gitx::Cli::IntegrateCommand do
46
47
  should meet_expectations
47
48
  end
48
49
  end
49
- context 'when current_branch == master' do
50
- let(:current_branch) { double('fake branch', name: 'master', head?: true) }
51
- let(:local_branch_names) { ['master'] }
50
+ context 'when current_branch == main' do
51
+ let(:current_branch) { double('fake branch', name: 'main', head?: true) }
52
+ let(:local_branch_names) { ['main'] }
52
53
  let(:remote_branch_names) { ['origin/staging'] }
53
54
  before do
54
55
  expect(executor).to receive(:execute).with('git', 'update').ordered
55
56
  expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
56
57
  expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
57
58
  expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
58
- expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrate master into staging', 'master').ordered
59
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrate main into staging', 'main').ordered
59
60
  expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
60
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
61
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
61
62
 
62
63
  cli.integrate
63
64
  end
@@ -84,7 +85,7 @@ describe Gitx::Cli::IntegrateCommand do
84
85
  expect(executor).to receive(:execute).with('git', 'update').ordered
85
86
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
86
87
  expect(executor).to receive(:execute).with('git', 'update').ordered
87
- expect(executor).to receive(:execute).with('git', 'log', 'origin/master...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return(changelog).ordered
88
+ expect(executor).to receive(:execute).with('git', 'log', 'origin/main...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return(changelog).ordered
88
89
  expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
89
90
  expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
90
91
  expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
@@ -108,7 +109,7 @@ describe Gitx::Cli::IntegrateCommand do
108
109
  context 'when staging branch does not exist remotely' do
109
110
  let(:remote_branch_names) { [] }
110
111
  before do
111
- expect(repo).to receive(:create_branch).with('staging', 'master')
112
+ expect(repo).to receive(:create_branch).with('staging', 'main')
112
113
 
113
114
  expect(executor).to receive(:execute).with('git', 'update').ordered
114
115
  expect(executor).to receive(:execute).with('git', 'push', 'origin', 'staging:staging').ordered
@@ -213,5 +214,29 @@ describe Gitx::Cli::IntegrateCommand do
213
214
  should meet_expectations
214
215
  end
215
216
  end
217
+ context 'with --skip-pull-request' do
218
+ let(:changelog) { '* made some fixes' }
219
+ let(:changelog) { '2013-01-01 did some stuff' }
220
+ let(:options) { { 'skip-pull-request': true } }
221
+ before do
222
+ allow(cli).to receive(:ask_editor).and_return('description')
223
+
224
+ expect(executor).to receive(:execute).with('git', 'update').ordered
225
+ expect(executor).to receive(:execute).with('git', 'fetch', 'origin').ordered
226
+ expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'staging').ordered
227
+ expect(executor).to receive(:execute).with('git', 'checkout', 'staging').ordered
228
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', '[gitx] Integrate feature-branch into staging', 'feature-branch').ordered
229
+ expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
230
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
231
+
232
+ cli.integrate
233
+ end
234
+ it 'does not create pull request' do
235
+ expect(WebMock).to_not have_requested(:post, 'https://api.github.com/repos/wireframe/gitx/pulls')
236
+ end
237
+ it 'runs expected commands' do
238
+ should meet_expectations
239
+ end
240
+ end
216
241
  end
217
242
  end
@@ -22,26 +22,26 @@ describe Gitx::Cli::NukeCommand do
22
22
  end
23
23
 
24
24
  describe '#nuke' do
25
- context 'when target branch == prototype and --destination == master' do
25
+ context 'when target branch == prototype and --destination == main' do
26
26
  let(:options) do
27
27
  {
28
28
  destination: good_branch
29
29
  }
30
30
  end
31
- let(:good_branch) { 'master' }
31
+ let(:good_branch) { 'main' }
32
32
  let(:bad_branch) { 'prototype' }
33
- let(:buildtag) { double(:tag, name: 'builds/master/2013-10-01-01') }
33
+ let(:buildtag) { double(:tag, name: 'builds/main/2013-10-01-01') }
34
34
  let(:tags) { [buildtag] }
35
35
  before do
36
36
  expect(cli).to receive(:yes?).and_return(true)
37
37
 
38
38
  expect(executor).to receive(:execute).with('git', 'fetch', '--tags').ordered
39
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
39
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
40
40
  expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'prototype').ordered
41
41
  expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'prototype').ordered
42
- expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'builds/master/2013-10-01-01').ordered
42
+ expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'builds/main/2013-10-01-01').ordered
43
43
  expect(executor).to receive(:execute).with('git', 'share').ordered
44
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
44
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
45
45
 
46
46
  cli.nuke bad_branch
47
47
  end
@@ -50,21 +50,21 @@ describe Gitx::Cli::NukeCommand do
50
50
  end
51
51
  end
52
52
  context 'when target branch == prototype and destination prompt == nil' do
53
- let(:good_branch) { 'master' }
53
+ let(:good_branch) { 'main' }
54
54
  let(:bad_branch) { 'prototype' }
55
- let(:buildtag) { double(:tag, name: 'builds/master/2013-10-01-01') }
55
+ let(:buildtag) { double(:tag, name: 'builds/main/2013-10-01-01') }
56
56
  let(:tags) { [buildtag] }
57
57
  before do
58
58
  expect(cli).to receive(:ask).and_return(good_branch)
59
59
  expect(cli).to receive(:yes?).and_return(true)
60
60
 
61
61
  expect(executor).to receive(:execute).with('git', 'fetch', '--tags').ordered
62
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
62
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
63
63
  expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'prototype').ordered
64
64
  expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'prototype').ordered
65
- expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'builds/master/2013-10-01-01').ordered
65
+ expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'builds/main/2013-10-01-01').ordered
66
66
  expect(executor).to receive(:execute).with('git', 'share').ordered
67
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
67
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
68
68
 
69
69
  cli.nuke 'prototype'
70
70
  end
@@ -73,14 +73,14 @@ describe Gitx::Cli::NukeCommand do
73
73
  end
74
74
  end
75
75
  context 'when user does not confirm nuking the target branch' do
76
- let(:buildtag) { double(:tag, name: 'builds/master/2013-10-01-01') }
76
+ let(:buildtag) { double(:tag, name: 'builds/main/2013-10-01-01') }
77
77
  let(:tags) { [buildtag] }
78
78
  before do
79
- expect(cli).to receive(:ask).and_return('master')
79
+ expect(cli).to receive(:ask).and_return('main')
80
80
  expect(cli).to receive(:yes?).and_return(false)
81
81
 
82
82
  expect(executor).to receive(:execute).with('git', 'fetch', '--tags').ordered
83
- expect(executor).to_not receive(:execute).with('git', 'checkout', 'master').ordered
83
+ expect(executor).to_not receive(:execute).with('git', 'checkout', 'main').ordered
84
84
 
85
85
  cli.nuke 'prototype'
86
86
  end
@@ -94,7 +94,7 @@ describe Gitx::Cli::NukeCommand do
94
94
  destination: good_branch
95
95
  }
96
96
  end
97
- let(:good_branch) { 'master' }
97
+ let(:good_branch) { 'main' }
98
98
  let(:bad_branch) { 'prototype' }
99
99
  let(:buildtags) { '' }
100
100
  it 'raises error' do
@@ -103,9 +103,9 @@ describe Gitx::Cli::NukeCommand do
103
103
  end
104
104
  end
105
105
  context 'when database migrations exist and user cancels operation' do
106
- let(:buildtag) { double(:tag, name: 'builds/master/2013-10-01-01') }
106
+ let(:buildtag) { double(:tag, name: 'builds/main/2013-10-01-01') }
107
107
  let(:tags) { [buildtag] }
108
- let(:good_branch) { 'master' }
108
+ let(:good_branch) { 'main' }
109
109
  let(:bad_branch) { 'prototype' }
110
110
  let(:migrations) do
111
111
  %w[db/migrate/20140715194946_create_users.rb db/migrate/20140730063034_update_user_account.rb].join("\n")
@@ -115,8 +115,8 @@ describe Gitx::Cli::NukeCommand do
115
115
 
116
116
  expect(executor).to receive(:execute).with('git', 'fetch', '--tags').ordered
117
117
  expect(cli).to receive(:ask).and_return(good_branch)
118
- expect(cli).to receive(:yes?).with('Reset prototype to builds/master/2013-10-01-01? (y/n)', :green).and_return(true)
119
- expect(executor).to receive(:execute).with('git', 'diff', 'builds/master/2013-10-01-01...prototype', '--name-only', 'db/migrate').and_return(migrations)
118
+ expect(cli).to receive(:yes?).with('Reset prototype to builds/main/2013-10-01-01? (y/n)', :green).and_return(true)
119
+ expect(executor).to receive(:execute).with('git', 'diff', 'builds/main/2013-10-01-01...prototype', '--name-only', 'db/migrate').and_return(migrations)
120
120
  expect(cli).to receive(:yes?).with('Are you sure you want to nuke prototype? (y/n) ', :green).and_return(false)
121
121
 
122
122
  cli.nuke 'prototype'
@@ -129,9 +129,9 @@ describe Gitx::Cli::NukeCommand do
129
129
  end
130
130
  end
131
131
  context 'when database migrations exist and user approves operation' do
132
- let(:buildtag) { double(:tag, name: 'builds/master/2013-10-01-01') }
132
+ let(:buildtag) { double(:tag, name: 'builds/main/2013-10-01-01') }
133
133
  let(:tags) { [buildtag] }
134
- let(:good_branch) { 'master' }
134
+ let(:good_branch) { 'main' }
135
135
  let(:bad_branch) { 'prototype' }
136
136
  let(:migrations) do
137
137
  %w[db/migrate/20140715194946_create_users.rb db/migrate/20140730063034_update_user_account.rb].join("\n")
@@ -140,17 +140,17 @@ describe Gitx::Cli::NukeCommand do
140
140
  FileUtils.mkdir_p('db/migrate')
141
141
 
142
142
  expect(cli).to receive(:ask).and_return(good_branch)
143
- expect(cli).to receive(:yes?).with('Reset prototype to builds/master/2013-10-01-01? (y/n)', :green).and_return(true)
144
- expect(executor).to receive(:execute).with('git', 'diff', 'builds/master/2013-10-01-01...prototype', '--name-only', 'db/migrate').and_return(migrations)
143
+ expect(cli).to receive(:yes?).with('Reset prototype to builds/main/2013-10-01-01? (y/n)', :green).and_return(true)
144
+ expect(executor).to receive(:execute).with('git', 'diff', 'builds/main/2013-10-01-01...prototype', '--name-only', 'db/migrate').and_return(migrations)
145
145
  expect(cli).to receive(:yes?).with('Are you sure you want to nuke prototype? (y/n) ', :green).and_return(true)
146
146
 
147
147
  expect(executor).to receive(:execute).with('git', 'fetch', '--tags').ordered
148
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
148
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
149
149
  expect(executor).to receive(:execute).with('git', 'branch', '--delete', '--force', 'prototype').ordered
150
150
  expect(executor).to receive(:execute).with('git', 'push', 'origin', '--delete', 'prototype').ordered
151
- expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'builds/master/2013-10-01-01').ordered
151
+ expect(executor).to receive(:execute).with('git', 'checkout', '-b', 'prototype', 'builds/main/2013-10-01-01').ordered
152
152
  expect(executor).to receive(:execute).with('git', 'share').ordered
153
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
153
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
154
154
 
155
155
  cli.nuke 'prototype'
156
156
  end
@@ -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
@@ -35,14 +36,14 @@ describe Gitx::Cli::ReleaseCommand do
35
36
  before do
36
37
  expect(repo).to receive(:workdir).and_return(temp_dir)
37
38
 
38
- expect(cli).to receive(:yes?).with('Release feature-branch to master? (y/n)', :green).and_return(true)
39
+ expect(cli).to receive(:yes?).with('Release feature-branch to main? (y/n)', :green).and_return(true)
39
40
  expect(cli).to receive(:yes?).with('Branch status is currently: failure. Proceed with release? (y/n)', :red).and_return(false)
40
41
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
41
42
 
42
43
  expect(executor).to receive(:execute).with('git', 'update').ordered
43
- expect(executor).to_not receive(:execute).with('git', 'checkout', 'master')
44
- expect(executor).to_not receive(:execute).with('git', 'pull', 'origin', 'master')
45
- expect(executor).to_not receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to master\n\nConnected to #10", 'feature-branch')
44
+ expect(executor).to_not receive(:execute).with('git', 'checkout', 'main')
45
+ expect(executor).to_not receive(:execute).with('git', 'pull', 'origin', 'main')
46
+ expect(executor).to_not receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to main\n\nConnected to #10", 'feature-branch')
46
47
  expect(executor).to_not receive(:execute).with('git', 'push', 'origin', 'HEAD')
47
48
 
48
49
  VCR.use_cassette('pull_request_does_exist_with_failure_status') do
@@ -58,15 +59,16 @@ 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
64
66
  expect(executor).to receive(:execute).with('git', 'update').ordered
65
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
66
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
67
- expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to master\n\nConnected to #10", 'feature-branch').ordered
67
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
68
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
69
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to main\n\nConnected to #10", 'feature-branch').ordered
68
70
  expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
69
- expect(executor).to receive(:execute).with('git integrate').ordered
71
+ expect(executor).to receive(:execute).with('git integrate --skip-pull-request').ordered
70
72
 
71
73
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
72
74
  cli.release
@@ -92,9 +94,9 @@ describe Gitx::Cli::ReleaseCommand do
92
94
 
93
95
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
94
96
  expect(executor).to receive(:execute).with('git', 'update').ordered
95
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
96
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
97
- expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to master\n\nConnected to #10", 'feature-branch').ordered
97
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
98
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
99
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to main\n\nConnected to #10", 'feature-branch').ordered
98
100
  expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
99
101
  expect(executor).to receive(:execute).with('echo hello').ordered
100
102
 
@@ -115,11 +117,11 @@ describe Gitx::Cli::ReleaseCommand do
115
117
 
116
118
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
117
119
  expect(executor).to receive(:execute).with('git', 'update').ordered
118
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
119
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
120
- expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to master\n\nConnected to #10", 'feature-branch').ordered
120
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
121
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
122
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to main\n\nConnected to #10", 'feature-branch').ordered
121
123
  expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
122
- expect(executor).to receive(:execute).with('git integrate').ordered
124
+ expect(executor).to receive(:execute).with('git integrate --skip-pull-request').ordered
123
125
 
124
126
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
125
127
  cli.release 'feature-branch'
@@ -145,19 +147,19 @@ describe Gitx::Cli::ReleaseCommand do
145
147
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
146
148
  allow(cli).to receive(:ask_editor).and_return('description')
147
149
 
148
- expect(cli).to receive(:yes?).with('Release feature-branch to master? (y/n)', :green).and_return(true)
150
+ expect(cli).to receive(:yes?).with('Release feature-branch to main? (y/n)', :green).and_return(true)
149
151
  expect(cli).to receive(:yes?).with('Branch status is currently: pending. Proceed with release? (y/n)', :red).and_return(true)
150
152
 
151
153
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
152
154
  expect(executor).to receive(:execute).with('git', 'update').ordered
153
155
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
154
156
  expect(executor).to receive(:execute).with('git', 'update').ordered
155
- expect(executor).to receive(:execute).with('git', 'log', 'origin/master...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return('2013-01-01 did some stuff').ordered
156
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
157
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
158
- expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to master\n\nConnected to #10", 'feature-branch').ordered
157
+ expect(executor).to receive(:execute).with('git', 'log', 'origin/main...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return('2013-01-01 did some stuff').ordered
158
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
159
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
160
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to main\n\nConnected to #10", 'feature-branch').ordered
159
161
  expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
160
- expect(executor).to receive(:execute).with('git integrate').ordered
162
+ expect(executor).to receive(:execute).with('git integrate --skip-pull-request').ordered
161
163
 
162
164
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls').to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
163
165
  VCR.use_cassette('pull_request_does_not_exist') do
@@ -185,11 +187,11 @@ describe Gitx::Cli::ReleaseCommand do
185
187
 
186
188
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
187
189
  expect(executor).to receive(:execute).with('git', 'update').ordered
188
- expect(executor).to receive(:execute).with('git', 'checkout', 'master').ordered
189
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
190
- expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to master\n\nConnected to #10", 'feature-branch').ordered
190
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
191
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
192
+ expect(executor).to receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to main\n\nConnected to #10", 'feature-branch').ordered
191
193
  expect(executor).to receive(:execute).with('git', 'push', 'origin', 'HEAD').ordered
192
- expect(executor).to receive(:execute).with('git integrate').ordered
194
+ expect(executor).to receive(:execute).with('git integrate --skip-pull-request').ordered
193
195
  expect(executor).to receive(:execute).with('git cleanup').ordered
194
196
 
195
197
  VCR.use_cassette('pull_request_does_exist_with_success_status') do
@@ -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 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', 'main')
222
+ expect(executor).to_not receive(:execute).with('git', 'pull', 'origin', 'main')
223
+ expect(executor).to_not receive(:execute).with('git', 'merge', '--no-ff', '--message', "[gitx] Release feature-branch to main\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 --skip-pull-request').ordered
229
+
230
+ VCR.use_cassette('pull_request_does_exist_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
@@ -46,7 +46,7 @@ describe Gitx::Cli::ReviewCommand do
46
46
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
47
47
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
48
48
  expect(executor).to receive(:execute).with('git', 'update').ordered
49
- expect(executor).to receive(:execute).with('git', 'log', 'origin/master...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return(changelog).ordered
49
+ expect(executor).to receive(:execute).with('git', 'log', 'origin/main...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return(changelog).ordered
50
50
  expect(cli).to receive(:ask_editor).with(changelog, hash_including(footer: Gitx::Github::PULL_REQUEST_FOOTER)).and_return('description')
51
51
 
52
52
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls').to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
@@ -82,11 +82,11 @@ describe Gitx::Cli::ReviewCommand do
82
82
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
83
83
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
84
84
  expect(executor).to receive(:execute).with('git', 'update').ordered
85
- expect(executor).to receive(:execute).with('git', 'log', 'origin/master...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return(changelog).ordered
85
+ expect(executor).to receive(:execute).with('git', 'log', 'origin/main...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return(changelog).ordered
86
86
  expect(cli).to receive(:ask_editor).with(changelog, hash_including(footer: Gitx::Github::PULL_REQUEST_FOOTER)).and_return(pull_request_description)
87
87
 
88
88
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls')
89
- .with(body: { base: 'master', head: 'feature-branch', title: 'feature branch', body: pull_request_description }.to_json)
89
+ .with(body: { base: 'main', head: 'feature-branch', title: 'feature branch', body: pull_request_description }.to_json)
90
90
  .to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
91
91
 
92
92
  VCR.use_cassette('pull_request_does_not_exist') do
@@ -16,9 +16,9 @@ describe Gitx::Cli::StartCommand do
16
16
  describe '#start' do
17
17
  context 'when user inputs branch that is valid' do
18
18
  before do
19
- expect(cli).to receive(:checkout_branch).with('master').ordered
19
+ expect(cli).to receive(:checkout_branch).with('main').ordered
20
20
  expect(executor).to receive(:execute).with('git', 'pull').ordered
21
- expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
21
+ expect(repo).to receive(:create_branch).with('new-branch', 'main').ordered
22
22
  expect(cli).to receive(:checkout_branch).with('new-branch').ordered
23
23
  expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', '[gitx] Start work on new-branch').ordered
24
24
 
@@ -30,9 +30,9 @@ describe Gitx::Cli::StartCommand do
30
30
  end
31
31
  context 'when user inputs branch with slash' do
32
32
  before do
33
- expect(cli).to receive(:checkout_branch).with('master').ordered
33
+ expect(cli).to receive(:checkout_branch).with('main').ordered
34
34
  expect(executor).to receive(:execute).with('git', 'pull').ordered
35
- expect(repo).to receive(:create_branch).with('foo/ryan', 'master').ordered
35
+ expect(repo).to receive(:create_branch).with('foo/ryan', 'main').ordered
36
36
  expect(cli).to receive(:checkout_branch).with('foo/ryan').ordered
37
37
  expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', '[gitx] Start work on foo/ryan').ordered
38
38
 
@@ -46,9 +46,9 @@ describe Gitx::Cli::StartCommand do
46
46
  before do
47
47
  expect(cli).to receive(:ask).and_return('new-branch')
48
48
 
49
- expect(cli).to receive(:checkout_branch).with('master').ordered
49
+ expect(cli).to receive(:checkout_branch).with('main').ordered
50
50
  expect(executor).to receive(:execute).with('git', 'pull').ordered
51
- expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
51
+ expect(repo).to receive(:create_branch).with('new-branch', 'main').ordered
52
52
  expect(cli).to receive(:checkout_branch).with('new-branch').ordered
53
53
  expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', '[gitx] Start work on new-branch').ordered
54
54
 
@@ -62,9 +62,9 @@ describe Gitx::Cli::StartCommand do
62
62
  before do
63
63
  expect(cli).to receive(:ask).and_return('new-branch')
64
64
 
65
- expect(cli).to receive(:checkout_branch).with('master').ordered
65
+ expect(cli).to receive(:checkout_branch).with('main').ordered
66
66
  expect(executor).to receive(:execute).with('git', 'pull').ordered
67
- expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
67
+ expect(repo).to receive(:create_branch).with('new-branch', 'main').ordered
68
68
  expect(cli).to receive(:checkout_branch).with('new-branch').ordered
69
69
  expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', '[gitx] Start work on new-branch').ordered
70
70
 
@@ -81,9 +81,9 @@ describe Gitx::Cli::StartCommand do
81
81
 
82
82
  expect(cli).to receive(:ask).and_return('new-branch')
83
83
 
84
- expect(cli).to receive(:checkout_branch).with('master').ordered
84
+ expect(cli).to receive(:checkout_branch).with('main').ordered
85
85
  expect(executor).to receive(:execute).with('git', 'pull').ordered
86
- expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
86
+ expect(repo).to receive(:create_branch).with('new-branch', 'main').ordered
87
87
  expect(cli).to receive(:checkout_branch).with('new-branch').ordered
88
88
  expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', '[gitx] Start work on new-branch').ordered
89
89
 
@@ -100,9 +100,9 @@ describe Gitx::Cli::StartCommand do
100
100
 
101
101
  expect(cli).to receive(:ask).and_return('new-branch')
102
102
 
103
- expect(cli).to receive(:checkout_branch).with('master').ordered
103
+ expect(cli).to receive(:checkout_branch).with('main').ordered
104
104
  expect(executor).to receive(:execute).with('git', 'pull').ordered
105
- expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
105
+ expect(repo).to receive(:create_branch).with('new-branch', 'main').ordered
106
106
  expect(cli).to receive(:checkout_branch).with('new-branch').ordered
107
107
  expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', '[gitx] Start work on new-branch').ordered
108
108
 
@@ -119,9 +119,9 @@ describe Gitx::Cli::StartCommand do
119
119
  }
120
120
  end
121
121
  before do
122
- expect(cli).to receive(:checkout_branch).with('master').ordered
122
+ expect(cli).to receive(:checkout_branch).with('main').ordered
123
123
  expect(executor).to receive(:execute).with('git', 'pull').ordered
124
- expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
124
+ expect(repo).to receive(:create_branch).with('new-branch', 'main').ordered
125
125
  expect(cli).to receive(:checkout_branch).with('new-branch').ordered
126
126
  expect(executor).to receive(:execute).with('git', 'commit', '--allow-empty', '--message', "[gitx] Start work on new-branch\n\nConnected to #10").ordered
127
127
 
@@ -138,9 +138,9 @@ describe Gitx::Cli::StartCommand do
138
138
  }
139
139
  end
140
140
  before do
141
- expect(cli).to receive(:checkout_branch).with('master').ordered
141
+ expect(cli).to receive(:checkout_branch).with('main').ordered
142
142
  expect(executor).to receive(:execute).with('git', 'pull').ordered
143
- expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
143
+ expect(repo).to receive(:create_branch).with('new-branch', 'main').ordered
144
144
  expect(cli).to receive(:checkout_branch).with('new-branch').ordered
145
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
146
 
@@ -27,8 +27,11 @@ describe Gitx::Cli::UpdateCommand do
27
27
  before do
28
28
  allow(cli).to receive(:say)
29
29
 
30
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
31
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
32
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
30
33
  expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').ordered
31
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
34
+ expect(executor).to receive(:execute).with('git', 'pull', '.', 'main').ordered
32
35
  expect(executor).to receive(:execute).with('git', 'share').ordered
33
36
 
34
37
  cli.update
@@ -41,6 +44,9 @@ describe Gitx::Cli::UpdateCommand do
41
44
  before do
42
45
  allow(cli).to receive(:say)
43
46
 
47
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
48
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
49
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
44
50
  expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'feature-branch').and_raise(Gitx::Executor::ExecutionError).ordered
45
51
 
46
52
  expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command')
@@ -49,12 +55,15 @@ describe Gitx::Cli::UpdateCommand do
49
55
  should meet_expectations
50
56
  end
51
57
  end
52
- context 'when merge conflicts occur when pulling remote master branch' do
58
+ context 'when merge conflicts occur when pulling remote main branch' do
53
59
  before do
54
60
  allow(cli).to receive(:say)
55
61
 
62
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
63
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
64
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
56
65
  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(Gitx::Executor::ExecutionError).ordered
66
+ expect(executor).to receive(:execute).with('git', 'pull', '.', 'main').and_raise(Gitx::Executor::ExecutionError).ordered
58
67
 
59
68
  expect { cli.update }.to raise_error(Gitx::Cli::BaseCommand::MergeError, 'Merge conflict occurred. Please fix merge conflict and rerun the command')
60
69
  end
@@ -68,7 +77,11 @@ describe Gitx::Cli::UpdateCommand do
68
77
  allow(cli).to receive(:say)
69
78
 
70
79
  expect(executor).not_to receive(:execute).with('git', 'pull', 'origin', 'feature-branch')
71
- expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'master').ordered
80
+ expect(executor).to receive(:execute).with('git', 'checkout', 'main').ordered
81
+ expect(executor).to receive(:execute).with('git', 'pull', 'origin', 'main').ordered
82
+ expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
83
+ expect(executor).to receive(:execute).with('git', 'pull', '.', 'main').ordered
84
+ expect(executor).to receive(:execute).with('git', 'share').ordered
72
85
 
73
86
  cli.update
74
87
  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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitx
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Sonnek
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2021-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -238,6 +238,7 @@ files:
238
238
  - lib/gitx/extensions/thor.rb
239
239
  - lib/gitx/github.rb
240
240
  - lib/gitx/version.rb
241
+ - spec/fixtures/vcr_cassettes/pull_request_does_exist_and_then_add_label.yml
241
242
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_failure_status.yml
242
243
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status.yml
243
244
  - spec/fixtures/vcr_cassettes/pull_request_does_not_exist.yml
@@ -266,7 +267,7 @@ homepage: ''
266
267
  licenses:
267
268
  - MIT
268
269
  metadata: {}
269
- post_install_message:
270
+ post_install_message:
270
271
  rdoc_options: []
271
272
  require_paths:
272
273
  - lib
@@ -274,18 +275,19 @@ 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
283
  version: '0'
283
284
  requirements: []
284
- rubygems_version: 3.1.2
285
- signing_key:
285
+ rubygems_version: 3.1.6
286
+ signing_key:
286
287
  specification_version: 4
287
288
  summary: Utility scripts for Git to increase productivity for common operations
288
289
  test_files:
290
+ - spec/fixtures/vcr_cassettes/pull_request_does_exist_and_then_add_label.yml
289
291
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_failure_status.yml
290
292
  - spec/fixtures/vcr_cassettes/pull_request_does_exist_with_success_status.yml
291
293
  - spec/fixtures/vcr_cassettes/pull_request_does_not_exist.yml