rebaser 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 5bf5a5c25788631d8326bbac9f4a5d2fbab8386d
4
- data.tar.gz: 8b200af6e4b7596aa9f07eb61109ddf7a165aeec
3
+ metadata.gz: 7477000b1abf1ca3434dd64432d437c547654aa1
4
+ data.tar.gz: 3e1957903d1c665ace7b020ef072dcc3d3eef2e2
5
5
  SHA512:
6
- metadata.gz: 72129e169435c4905c978d78e756abd8abe33259ad7de6bf2a9f0455523c746a60061fd99cfc5a1ebd8d6794f0c5d73c9edec0d71966d1d3bb5dba5b0b34867c
7
- data.tar.gz: f21b73dd4c264383e12544fac1c3b3835f5b9e745e5b4e99d0acafe41db63b2eeb018d200a42bebc48052342400978303d725b56b1b8b0a69f3ccf6ded6c55ce
6
+ metadata.gz: b95d38e48cf2da578e855a4bbcb42f54814fe7a2bc693b29054952b2ec322a7a425f4ce4bd943fc1d75e1eb9a97189185f443a8aeed1ea076e0336090fc75a55
7
+ data.tar.gz: de88c3ae0c796678023f7ceb751815a42dc1069fa94a0be6af7baca0bc9ae6c97c748dc3d6ce8d9d272873846e5ffcf2a4a059cffaa70f0f7417646a837a66d0
@@ -2,11 +2,12 @@ require 'github_api'
2
2
 
3
3
  module Rebaser
4
4
  class OpenBranchFetcher
5
- def initialize(username:, password:, token:, remote:)
5
+ def initialize(username:, password:, token:, remote:, rebase_branch:)
6
6
  @username = username
7
7
  @password = password
8
8
  @token = token
9
9
  @remote = remote
10
+ @rebase_branch = rebase_branch
10
11
  end
11
12
 
12
13
  def fetch
@@ -23,11 +24,11 @@ module Rebaser
23
24
 
24
25
  pull_requests = github.pull_requests.list remote_user, remote_repo, state: 'open'
25
26
 
26
- branches = pull_requests.map { |pr| pr.head.ref }
27
+ branches = pull_requests.map { |pr| pr.head.ref if pr.base.ref === rebase_branch }.compact
27
28
  branches
28
29
  end
29
30
 
30
31
  private
31
- attr_reader :username, :password, :token, :remote
32
+ attr_reader :username, :password, :token, :remote, :rebase_branch
32
33
  end
33
34
  end
@@ -1,3 +1,3 @@
1
1
  module Rebaser
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/rebaser.rb CHANGED
@@ -32,16 +32,22 @@ module Rebaser
32
32
  end
33
33
  end
34
34
 
35
+ unless options[:rebase_branch]
36
+ options[:rebase_branch] = Ask.input "Please enter the branch to rebase onto", default: 'master'
37
+ end
38
+
35
39
  branches = OpenBranchFetcher.new(
36
40
  username: options[:username],
37
41
  password: options[:password],
38
42
  token: options[:token],
39
43
  remote: options[:remote],
44
+ rebase_branch: options[:rebase_branch],
40
45
  ).fetch
41
46
 
42
47
  puts "\n\nHere's what I'll be rebasing today:\n"
43
48
  puts branches
44
49
  puts "\nI'll rebase these branches onto #{options[:rebase_branch]}."
50
+ puts "I'll only rebase if the pull request is opened against the target branch."
45
51
  puts "If I run into merge conflicts, I'll skip that branch."
46
52
  puts "This can be dangerous as I will be force pushing."
47
53
  continue = Ask.confirm "Are you sure you want to continue?", default: false
@@ -49,9 +55,6 @@ module Rebaser
49
55
  return unless continue
50
56
 
51
57
  remote = Ask.input "Please enter the remote name to push to", default: 'origin'
52
- unless options[:rebase_branch]
53
- options[:rebase_branch] = Ask.input "Please enter the branch to rebase onto", default: 'master'
54
- end
55
58
 
56
59
  rebaser = Rebaser.new(branches, options[:rebase_branch], remote)
57
60
  rebaser.begin
data/rebaser.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_development_dependency 'bundler', '~> 1.6'
21
21
  spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'pry'
22
23
  spec.add_runtime_dependency 'github_api'
23
24
  spec.add_runtime_dependency 'inquirer'
24
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rebaser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Minkov
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: github_api
43
57
  requirement: !ruby/object:Gem::Requirement