git_commands 3.3.7 → 3.4.0

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
  SHA1:
3
- metadata.gz: 4b9df5d09769634c3dc383e862a2a0f6effe9141
4
- data.tar.gz: 2e903481e8ad0a0a7efa12ccc018f55158d418eb
3
+ metadata.gz: c4e5ee0c7fb792943323a8df9f026e46ed043c2e
4
+ data.tar.gz: a1d6e9c1709de3a742c9c20aa22cfbd6bdc86290
5
5
  SHA512:
6
- metadata.gz: 7430f5fcd09df1229cbc6dab10631e54a37cd6209df1a529910a18f89932ad62647ce07639932cc31633e576f10258f6372e192972381de8b6449ba69ee09aa9
7
- data.tar.gz: 02a8e71e2f28e97f92eec396a25394e49afa2a156983f7ce5c595de98e2c7868f43ce9bb45eaa8945077e959d592f27dbcb2abeae9862811bcdb6acb0081bc46
6
+ metadata.gz: 725df66a77dd900e4f2c2aa5543c1e25ffc24d62cc332bc9e8fb7d7d29123f0eac821a57b8912d56c039eebcc1135f3ae1187531cddcfeb10c8f204e87854d53
7
+ data.tar.gz: 2b3162474ae63758828d6c1e9dc071c813a92565200e7a69d91c4808507718f11b62a05ab6598da26035e7c4fc95c3c6db38e6724f2d2c5ffda8b9a899836042
data/README.md CHANGED
@@ -51,6 +51,7 @@ rebase --help
51
51
  Usage: rebase --repo=/Users/Elvis/greatest_hits --branches=feature/love_me_tender,fetaure/teddybear
52
52
  -r, --repo=REPO The path to the existing GIT repository
53
53
  -b, --branches=BRANCHES Specify branches as: 1. a comma-separated list of names 2. the path to a file containing names on each line 3. via pattern matching
54
+ -t, --target=TARGET Specify the target branch, default to master
54
55
  -h, --help Prints this help
55
56
  ```
56
57
 
@@ -147,7 +148,7 @@ Successfully loaded 1 branch:
147
148
  Here are the available GIT commands:
148
149
 
149
150
  #### Rebase
150
- This command is useful in case you have several branches to rebase with _origin/master_ frequently.
151
+ This command is useful in case you have several branches to rebase with _origin/master_ (or another specified target) frequently.
151
152
  A confirmation is asked to before rebasing.
152
153
 
153
154
  ```
@@ -155,6 +156,19 @@ rebase --repo=/Users/Elvis/greatest_hits --branches=feature/love_me_tender,featu
155
156
  ...
156
157
  ```
157
158
 
159
+ ##### Target branch
160
+ The rebasing runs considering master branch as the target one.
161
+ In case you need to rebase against a different target branch you can specify it:
162
+ ```
163
+ rebase --repo=/Users/Elvis/greatest_hits --target=rc/release_to_graceland --branches=feature/love_me_tender
164
+
165
+ Loading branches file...
166
+ Successfully loaded 1 branch:
167
+ 01. feature/love_me_tender
168
+
169
+ Proceed rebasing these branches with rc/release_to_graceland (Y/N)?
170
+ ```
171
+
158
172
  #### Remove
159
173
  This command remove the specified branches locally and remotely.
160
174
  A confirmation is asked before removal.
@@ -20,13 +20,17 @@ module GitCommands
20
20
 
21
21
  def call
22
22
  parser.parse!(@args)
23
- computer = @computer_klass.new(repo: @repo, branches: @branches)
23
+ computer = @computer_klass.new(repo: @repo, branches: @branches, target: target)
24
24
  computer.send(@command_name)
25
25
  rescue Repository::PathError, Computer::GitError, AbortError, Repository::InvalidError => e
26
26
  error(e.message)
27
27
  exit
28
28
  end
29
29
 
30
+ private def target
31
+ @target || Branch::MASTER
32
+ end
33
+
30
34
  private def check_command_name(name)
31
35
  return name if VALID_COMMANDS.include?(name)
32
36
  fail UnknownCommandError, "#{name} is not a supported command"
@@ -44,6 +48,10 @@ module GitCommands
44
48
  @branches = branches
45
49
  end
46
50
 
51
+ opts.on("-tTARGET", "--target=TARGET", "Specify the target branch, default to master") do |target|
52
+ @target = target
53
+ end
54
+
47
55
  opts.on("-h", "--help", "Prints this help") do
48
56
  @out.puts opts
49
57
  exit
@@ -9,10 +9,12 @@ module GitCommands
9
9
  class GitError < StandardError; end
10
10
 
11
11
  attr_reader :out
12
+ attr_accessor :target
12
13
 
13
- def initialize(repo:, branches:, repo_klass: Repository, branch_klass: Branch, out: STDOUT)
14
+ def initialize(repo:, branches:, target: Branch::MASTER, repo_klass: Repository, branch_klass: Branch, out: STDOUT)
14
15
  @out = out
15
16
  @repo = repo_klass.new(repo)
17
+ @target = target
16
18
  Dir.chdir(@repo) do
17
19
  @branches = branch_klass.factory(branches)
18
20
  @timestamp = Time.new.strftime("%Y-%m-%d")
@@ -33,7 +35,7 @@ module GitCommands
33
35
  end
34
36
 
35
37
  def rebase
36
- confirm("Proceed rebasing these branches with master") do
38
+ confirm("Proceed rebasing these branches with #{@target}") do
37
39
  enter_repo do
38
40
  @branches.each do |branch|
39
41
  warning("Rebasing branch: #{branch}")
@@ -76,12 +78,12 @@ module GitCommands
76
78
  @out.puts @branches.each_with_index.map { |branch, i| "#{(i+1).to_s.rjust(2, "0")}. #{branch}" } + [""]
77
79
  end
78
80
 
79
- private def pull_master
80
- `git checkout #{Branch::MASTER}`
81
+ private def align
82
+ `git checkout #{@target}`
81
83
  `git pull`
82
84
  end
83
85
 
84
- private def rebase_with(branch = "#{Branch::ORIGIN}#{Branch::MASTER}")
86
+ private def rebase_with(branch = "#{Branch::ORIGIN}#{@target}")
85
87
  `git rebase #{branch}`
86
88
  return true unless @repo.locked?
87
89
  @repo.unlock
@@ -90,13 +92,13 @@ module GitCommands
90
92
 
91
93
  private def enter_repo
92
94
  Dir.chdir(@repo) do
93
- pull_master
95
+ align
94
96
  yield
95
97
  end
96
98
  end
97
99
 
98
100
  private def remove_locals(branches = @branches)
99
- `git checkout #{Branch::MASTER}`
101
+ `git checkout #{@target}`
100
102
  branches.each do |branch|
101
103
  `git branch -D #{branch}`
102
104
  end
@@ -1,3 +1,3 @@
1
1
  module GitCommands
2
- VERSION = "3.3.7"
2
+ VERSION = "3.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.7
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-28 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.5.1
105
+ rubygems_version: 2.6.8
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Utility library to rebase and aggregate your project branches