git_pretty_accept 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1bb08233347e08a6009b258782b3bb44798f530f
4
+ data.tar.gz: 224d416caa7722a452245b09fd3bd684addd3a84
5
+ SHA512:
6
+ metadata.gz: 309b1c8978ec26fecb968dfce874f7cac64fd33ef3fb2662c125659f2b97a5ed558886692866c621c2ab430d3fa50c930231213bb570c190f367247cfc9a1bc5
7
+ data.tar.gz: e51b2679cd21202663a487eb937657b20f8db223a1e4d04f8bce32fb949fd7a505de5e1b09cad4b374b76d945e7923af73b5aa8bfb5484abce2833f6937ae7a0
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.3 - 2013-11-23
2
+
3
+ * Specify branches when pulling and pushing to origin.
4
+ * Abort script if pull request branch is master.
5
+
1
6
  ## 0.1.2 - 2013-11-14
2
7
 
3
8
  * Force delete local pull request branch if it's been rebased.
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  spec.add_dependency 'git'
28
- spec.add_dependency('methadone', '~> 1.3.1')
28
+ spec.add_dependency 'methadone', '~> 1.3.1'
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.3"
31
- spec.add_development_dependency('rdoc')
32
- spec.add_development_dependency('debugger')
33
- spec.add_development_dependency('rake', '~> 0.9.2')
34
- spec.add_development_dependency('rspec')
35
- spec.add_development_dependency('rspec-example_steps')
30
+ spec.add_development_dependency 'bundler', '~> 1.3'
31
+ spec.add_development_dependency 'pry'
32
+ spec.add_development_dependency 'rdoc'
33
+ spec.add_development_dependency 'rake'
34
+ spec.add_development_dependency 'rspec'
35
+ spec.add_development_dependency 'rspec-example_steps'
36
36
  end
@@ -4,28 +4,37 @@ module GitPrettyAccept
4
4
  include Methadone::CLILogging
5
5
 
6
6
  main do |branch|
7
- options[:edit] = true if options[:edit].nil?
8
-
9
- our = Git.open('.')
10
- source_branch = our.branches.find(&:current).to_s
11
-
12
- commands = [
13
- "git pull",
14
- "git checkout #{branch}",
15
- "git rebase #{source_branch}",
16
- "git checkout #{source_branch}",
17
- "git merge --no-ff #{options[:edit] ? '--edit' : '--no-edit'} #{branch}",
18
- "git push",
19
- "git branch -D #{branch}",
20
- "git push origin :#{branch}"
21
- ]
22
-
23
- commands.each_with_index do |command, i|
24
- puts "\n#{command}"
25
- unless system(command)
26
- puts "\nDue to the error above, the following commands were not executed: "
27
- puts commands[i + 1, commands.size].join("\n")
28
- exit!
7
+ if branch == 'master'
8
+ error "You're trying to accept master as a pull request branch. " +
9
+ "Please checkout to master instead and accept this branch " +
10
+ "from there."
11
+ exit!
12
+ else
13
+ options[:edit] = true if options[:edit].nil?
14
+
15
+ our = Git.open('.')
16
+ source_branch = our.branches.find(&:current).to_s
17
+
18
+ commands = [
19
+ "git pull origin #{source_branch}",
20
+ "git checkout #{branch}",
21
+ "git rebase origin/#{source_branch}",
22
+ "git push --force origin #{branch}",
23
+ "git checkout #{source_branch}",
24
+ "git merge --no-ff #{options[:edit] ? '--edit' : '--no-edit'} #{branch}",
25
+ "git push origin #{source_branch}",
26
+ "git branch -D #{branch}",
27
+ "git push origin :#{branch}"
28
+ ]
29
+
30
+ commands.each_with_index do |command, i|
31
+ info "\n#{command}"
32
+ unless system(command)
33
+ error "\nDue to the error above, " +
34
+ "the following commands were not executed: " +
35
+ commands[i + 1, commands.size].join("\n")
36
+ exit!
37
+ end
29
38
  end
30
39
  end
31
40
  end
@@ -1,3 +1,3 @@
1
1
  module GitPrettyAccept
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -56,7 +56,7 @@ describe GitPrettyAccept::App do
56
56
 
57
57
  When 'I run `git pretty-accept PR_BRANCH`' do
58
58
  FileUtils.cd(our_path) do
59
- `#{project_path}/bin/git-pretty-accept --no-edit #{pr_branch}`
59
+ `bundle exec #{project_path}/bin/git-pretty-accept --no-edit #{pr_branch}`
60
60
  expect($CHILD_STATUS.exitstatus).to eq(0)
61
61
  end
62
62
  end
@@ -67,10 +67,10 @@ describe GitPrettyAccept::App do
67
67
  expect(our.log[0].message).to eq("Merge branch 'pr_branch'")
68
68
  expect(our.log[0].parents.size).to eq(2)
69
69
 
70
- expect(our.log[1].message).to eq('Add changelog')
70
+ expect(our.log[1].message).to eq('Update readme')
71
71
  expect(our.log[1].parents.size).to eq(1)
72
72
 
73
- expect(our.log[2].message).to eq('Update readme')
73
+ expect(our.log[2].message).to eq('Add changelog')
74
74
  expect(our.log[2].parents.size).to eq(1)
75
75
 
76
76
  expect(our.log[3].message).to eq('Add readme')
@@ -90,4 +90,23 @@ describe GitPrettyAccept::App do
90
90
  expect(our.branches["origin/#{pr_branch}"]).to be_nil
91
91
  end
92
92
  end
93
+
94
+ Steps "should not allow master to be accepted as a PR branch" do
95
+ Given 'I have a local repo' do
96
+ Git.init(our_path)
97
+ end
98
+
99
+ When 'I run `git pretty-accept master`' do
100
+ command = "bundle exec #{project_path}/bin/git-pretty-accept --no-edit master"
101
+ FileUtils.cd(our_path) do
102
+ @result = system(command, err: '/tmp/err.log')
103
+ end
104
+ end
105
+
106
+ Then 'I should be informed that master cannot be accepted as a PR branch' do
107
+ expect(@result).to be_false
108
+ expect(File.read('/tmp/err.log')).to include(
109
+ 'trying to accept master as a pull request branch')
110
+ end
111
+ end
93
112
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'debugger'
1
+ require 'pry'
2
2
  require 'git_pretty_accept'
3
3
  # This file was generated by the `rspec --init` command. Conventionally, all
4
4
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
metadata CHANGED
@@ -1,145 +1,128 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_pretty_accept
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - George Mendoza
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-14 00:00:00.000000000 Z
11
+ date: 2013-11-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
14
+ name: git
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- none: false
20
+ type: :runtime
21
+ prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
- - - ! '>='
24
+ - - '>='
24
25
  - !ruby/object:Gem::Version
25
26
  version: '0'
26
- none: false
27
- prerelease: false
28
- name: git
29
- type: :runtime
30
27
  - !ruby/object:Gem::Dependency
28
+ name: methadone
31
29
  requirement: !ruby/object:Gem::Requirement
32
30
  requirements:
33
31
  - - ~>
34
32
  - !ruby/object:Gem::Version
35
33
  version: 1.3.1
36
- none: false
34
+ type: :runtime
35
+ prerelease: false
37
36
  version_requirements: !ruby/object:Gem::Requirement
38
37
  requirements:
39
38
  - - ~>
40
39
  - !ruby/object:Gem::Version
41
40
  version: 1.3.1
42
- none: false
43
- prerelease: false
44
- name: methadone
45
- type: :runtime
46
41
  - !ruby/object:Gem::Dependency
42
+ name: bundler
47
43
  requirement: !ruby/object:Gem::Requirement
48
44
  requirements:
49
45
  - - ~>
50
46
  - !ruby/object:Gem::Version
51
47
  version: '1.3'
52
- none: false
48
+ type: :development
49
+ prerelease: false
53
50
  version_requirements: !ruby/object:Gem::Requirement
54
51
  requirements:
55
52
  - - ~>
56
53
  - !ruby/object:Gem::Version
57
54
  version: '1.3'
58
- none: false
59
- prerelease: false
60
- name: bundler
61
- type: :development
62
55
  - !ruby/object:Gem::Dependency
56
+ name: pry
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
- - - ! '>='
59
+ - - '>='
66
60
  - !ruby/object:Gem::Version
67
61
  version: '0'
68
- none: false
62
+ type: :development
63
+ prerelease: false
69
64
  version_requirements: !ruby/object:Gem::Requirement
70
65
  requirements:
71
- - - ! '>='
66
+ - - '>='
72
67
  - !ruby/object:Gem::Version
73
68
  version: '0'
74
- none: false
75
- prerelease: false
76
- name: rdoc
77
- type: :development
78
69
  - !ruby/object:Gem::Dependency
70
+ name: rdoc
79
71
  requirement: !ruby/object:Gem::Requirement
80
72
  requirements:
81
- - - ! '>='
73
+ - - '>='
82
74
  - !ruby/object:Gem::Version
83
75
  version: '0'
84
- none: false
76
+ type: :development
77
+ prerelease: false
85
78
  version_requirements: !ruby/object:Gem::Requirement
86
79
  requirements:
87
- - - ! '>='
80
+ - - '>='
88
81
  - !ruby/object:Gem::Version
89
82
  version: '0'
90
- none: false
91
- prerelease: false
92
- name: debugger
93
- type: :development
94
83
  - !ruby/object:Gem::Dependency
84
+ name: rake
95
85
  requirement: !ruby/object:Gem::Requirement
96
86
  requirements:
97
- - - ~>
87
+ - - '>='
98
88
  - !ruby/object:Gem::Version
99
- version: 0.9.2
100
- none: false
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
101
92
  version_requirements: !ruby/object:Gem::Requirement
102
93
  requirements:
103
- - - ~>
94
+ - - '>='
104
95
  - !ruby/object:Gem::Version
105
- version: 0.9.2
106
- none: false
107
- prerelease: false
108
- name: rake
109
- type: :development
96
+ version: '0'
110
97
  - !ruby/object:Gem::Dependency
98
+ name: rspec
111
99
  requirement: !ruby/object:Gem::Requirement
112
100
  requirements:
113
- - - ! '>='
101
+ - - '>='
114
102
  - !ruby/object:Gem::Version
115
103
  version: '0'
116
- none: false
104
+ type: :development
105
+ prerelease: false
117
106
  version_requirements: !ruby/object:Gem::Requirement
118
107
  requirements:
119
- - - ! '>='
108
+ - - '>='
120
109
  - !ruby/object:Gem::Version
121
110
  version: '0'
122
- none: false
123
- prerelease: false
124
- name: rspec
125
- type: :development
126
111
  - !ruby/object:Gem::Dependency
112
+ name: rspec-example_steps
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - ! '>='
115
+ - - '>='
130
116
  - !ruby/object:Gem::Version
131
117
  version: '0'
132
- none: false
118
+ type: :development
119
+ prerelease: false
133
120
  version_requirements: !ruby/object:Gem::Requirement
134
121
  requirements:
135
- - - ! '>='
122
+ - - '>='
136
123
  - !ruby/object:Gem::Version
137
124
  version: '0'
138
- none: false
139
- prerelease: false
140
- name: rspec-example_steps
141
- type: :development
142
- description: ! ' `git-pretty-accept` is a script that rebases a pull request before
125
+ description: ' `git-pretty-accept` is a script that rebases a pull request before
143
126
  merging to master. Pull requests are _always_ merged recursively. The result is
144
127
  a linear history with merge bubbles indicating pull requests. In short, pretty. '
145
128
  email:
@@ -165,33 +148,26 @@ files:
165
148
  homepage: https://github.com/gsmendoza/git_pretty_accept
166
149
  licenses:
167
150
  - MIT
151
+ metadata: {}
168
152
  post_install_message:
169
153
  rdoc_options: []
170
154
  require_paths:
171
155
  - lib
172
156
  required_ruby_version: !ruby/object:Gem::Requirement
173
157
  requirements:
174
- - - ! '>='
158
+ - - '>='
175
159
  - !ruby/object:Gem::Version
176
- hash: 150844083
177
160
  version: '0'
178
- segments:
179
- - 0
180
- none: false
181
161
  required_rubygems_version: !ruby/object:Gem::Requirement
182
162
  requirements:
183
- - - ! '>='
163
+ - - '>='
184
164
  - !ruby/object:Gem::Version
185
- hash: 150844083
186
165
  version: '0'
187
- segments:
188
- - 0
189
- none: false
190
166
  requirements: []
191
167
  rubyforge_project:
192
- rubygems_version: 1.8.24
168
+ rubygems_version: 2.1.11
193
169
  signing_key:
194
- specification_version: 3
170
+ specification_version: 4
195
171
  summary: Accept pull requests, the pretty way
196
172
  test_files:
197
173
  - spec/git_pretty_accept/app_spec.rb