gitx 4.1.0 → 4.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59f45788834b6e13ec3fd859fe45cde1d4f84f1205866f0b72dd6800d40b6e5d
4
- data.tar.gz: a08cd9beca1c16bc02f5654ed056e7e93d89e21df5914cb7507c04d679b6f1ec
3
+ metadata.gz: 3794617867e08f0a15468dd3291883d22bed44fa9dfde0350cf120e5c5c8890c
4
+ data.tar.gz: 827802ca75c6a1f4243fa628a12dc3cc1e9b11afef91d587fc9fe4ae4a9b2b6e
5
5
  SHA512:
6
- metadata.gz: 8d464966f06a39cadd33a9830130c5f25edbed7eccba994ce96fee827a1f8e9cdaa75dd4c3553338774b15fb5de2ce5185882034e506c6057b6d1a12f92b67d9
7
- data.tar.gz: ac922c59dae45ed1d87c5e86c719628e2dfc55d13daffb9b9891cc01ced3672573c2916dbb6b9290fe8ae6ef5fe846322d71e574bf7c092bf39c32f249c35a22
6
+ metadata.gz: ae00b7739d6b3488d0ae4ae588d776c1a004eeb36167587699d2c0dae2ec49902dfc78d122f1edcab7e9ce47a3cecfd36efe59491bce0d663562058e08975f57
7
+ data.tar.gz: 8727bf623a20f50a6de72088a0e1106e26ccd1ba974d66471e2ed0f8643ffe3c04ec299b6d4343df3816f8c881af3588497e7a2fd9806627c418d461933d24dc
data/lib/gitx/github.rb CHANGED
@@ -17,6 +17,7 @@ module Gitx
17
17
  #
18
18
  # This footer will automatically be stripped from the pull request description
19
19
  MESSAGE
20
+ PULL_REQEST_TEMPLATE_FILE='.github/PULL_REQUEST_TEMPLATE.md'
20
21
 
21
22
  def find_or_create_pull_request(branch)
22
23
  pull_request = find_pull_request(branch)
@@ -82,6 +83,7 @@ module Gitx
82
83
  description_template = []
83
84
  description_template << "#{description}\n" if description
84
85
  description_template << changelog
86
+ description_template << "#{pull_request_template}\n" if pull_request_template
85
87
 
86
88
  ask_editor(description_template.join("\n"), editor: repo.config['core.editor'], footer: PULL_REQUEST_FOOTER)
87
89
  end
@@ -90,6 +92,14 @@ module Gitx
90
92
  options[:title] || branch.gsub(/[-_]/, ' ')
91
93
  end
92
94
 
95
+ def pull_request_template_file
96
+ File.expand_path(PULL_REQEST_TEMPLATE_FILE)
97
+ end
98
+
99
+ def pull_request_template
100
+ @pull_request_template ||= File.exist?(pull_request_template_file) ? File.read(pull_request_template_file) : nil
101
+ end
102
+
93
103
  # authorization token used for github API calls
94
104
  # the token is cached on the filesystem for future use
95
105
  # @return [String] auth token stored in git (current repo, user config or installed global settings)
data/lib/gitx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gitx
2
- VERSION = '4.1.0'.freeze
2
+ VERSION = '4.1.1'.freeze
3
3
  end
@@ -63,8 +63,12 @@ describe Gitx::Cli::ReviewCommand do
63
63
  end
64
64
  end
65
65
  context 'when target branch is not nil and pull request does not exist' do
66
+ subject(:review) do
67
+ VCR.use_cassette('pull_request_does_not_exist') do
68
+ cli.review 'feature-branch'
69
+ end
70
+ end
66
71
  let(:authorization_token) { '123123' }
67
- let(:changelog) { '* made some fixes' }
68
72
  let(:fake_update_command) { double('fake update command', update: nil) }
69
73
  let(:new_pull_request) do
70
74
  {
@@ -77,21 +81,18 @@ describe Gitx::Cli::ReviewCommand do
77
81
  }
78
82
  end
79
83
  let(:changelog) { "* old commit\n\n* new commit" }
84
+ let(:pull_request_body) { changelog }
80
85
  let(:pull_request_description) { 'description' }
81
86
  before do
82
87
  allow(cli).to receive(:authorization_token).and_return(authorization_token)
83
88
  expect(executor).to receive(:execute).with('git', 'checkout', 'feature-branch').ordered
84
89
  expect(executor).to receive(:execute).with('git', 'update').ordered
85
90
  expect(executor).to receive(:execute).with('git', 'log', 'origin/main...feature-branch', '--reverse', '--no-merges', '--pretty=format:* %B').and_return(changelog).ordered
86
- expect(cli).to receive(:ask_editor).with(changelog, hash_including(footer: Gitx::Github::PULL_REQUEST_FOOTER)).and_return(pull_request_description)
91
+ expect(cli).to receive(:ask_editor).with(pull_request_body, hash_including(footer: Gitx::Github::PULL_REQUEST_FOOTER)).and_return(pull_request_description)
87
92
 
88
93
  stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls')
89
94
  .with(body: { base: 'main', head: 'feature-branch', title: 'feature branch', body: pull_request_description }.to_json)
90
95
  .to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
91
-
92
- VCR.use_cassette('pull_request_does_not_exist') do
93
- cli.review 'feature-branch'
94
- end
95
96
  end
96
97
  it 'creates github pull request' do
97
98
  should meet_expectations
@@ -99,6 +100,28 @@ describe Gitx::Cli::ReviewCommand do
99
100
  it 'runs expected commands' do
100
101
  should meet_expectations
101
102
  end
103
+ context 'when PULL_REQUEST_TEMPLATE file exists' do
104
+ let(:pull_request_template) do
105
+ "## Summary\nPut your summary here\n## Artifacts\n- list\n- your\n-artifacts"
106
+ end
107
+ let(:pull_request_body) do
108
+ "#{changelog}\n#{pull_request_template}\n"
109
+ end
110
+ before do
111
+ expect(cli).to receive(:pull_request_template).and_return(pull_request_template).twice
112
+
113
+ stub_request(:post, 'https://api.github.com/repos/wireframe/gitx/pulls')
114
+ .with(body: { base: 'main', head: 'feature-branch', title: 'feature branch', body: pull_request_description }.to_json)
115
+ .to_return(status: 201, body: new_pull_request.to_json, headers: { 'Content-Type' => 'application/json' })
116
+ end
117
+
118
+ it 'creates github pull request' do
119
+ should meet_expectations
120
+ end
121
+ it 'runs expected commands' do
122
+ should meet_expectations
123
+ end
124
+ end
102
125
  end
103
126
  context 'when authorization_token is missing' do
104
127
  let(:authorization_token) { nil }
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: 4.1.0
4
+ version: 4.1.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: 2021-05-26 00:00:00.000000000 Z
11
+ date: 2021-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit