ding 1.2.5 → 1.3.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: 852f8d7b2c81e1f9add37fc53fa7c1451507beb8
4
- data.tar.gz: bea5f5455250cd77a750981d0095bc96ba93bce8
3
+ metadata.gz: 180b7234cd043dfd76225d56d47570ec10706bac
4
+ data.tar.gz: 172c523dcd96ae30955fc186ddc4aae228e45b1f
5
5
  SHA512:
6
- metadata.gz: 89077adae81bba83de931a1ab9dd14a821e33b9c4f573e51a73dca48a9285959dde0fe981b91c7779bbc3df08d5936ea406baf561dee279bdc39b6fd3ac3d7e4
7
- data.tar.gz: bd458bcc277ddb7d01e6bd6e977503859972ab12127c3c924c92edaab63ce20299488e5dd8e1ed95ca7b568196e275bd1275da35bb96daf209b7557387b7b532
6
+ metadata.gz: 91f84d350bd8750d8c61584edbbe890bd24888e9e4f4eceaa02b74e184c07a25be23d32ec9bc6cdbe1021e364e206ea92238b53a63db21c11ea3e5de0cda7b6c
7
+ data.tar.gz: fb79be5665c7d84a51ca379a17aac8ba51c3f5b73ca056e47096df9f9452d8970bef249320fac721258b84bd226038fe0cf97da8c9069cbeda728510b86c5baf
data/README.md CHANGED
@@ -57,11 +57,12 @@ listed, this can be over-ridden by using the `-m` flag.
57
57
  ding push
58
58
 
59
59
  Options:
60
- -b, [--branch=BRANCH] # specify an over-ride destination branch
60
+ -b, [--branch=BRANCH] # specify an over-ride for the testingbranch
61
61
  -l, [--local], [--no-local] # operate on local branches (merged from remote)
62
62
  -m, [--merged], [--no-merged] # display branches that have been merged
63
- -p, [--pattern=PATTERN] # specify a pattern for listing branches
63
+ -p, [--pattern=PATTERN] # specify a pattern for listing feature branches
64
64
  # Default: *XAP*
65
+ -s, [--skip], [--no-skip] # skip feature branch selection; just push develop to testing
65
66
  -f, [--force] # use the force on commands that allow it e.g. git push
66
67
  # Default: true
67
68
  -v, [--verbose], [--no-verbose] # show verbose output such as full callstack on errors
@@ -8,24 +8,34 @@ module Ding
8
8
 
9
9
  default_task :push
10
10
 
11
- desc "push", "Push feature branch(es) to the testing branch (this is the default action)"
12
- option :branch, type: 'string', aliases: '-b', default: nil, desc: 'specify an over-ride destination branch'
13
- option :local, type: 'boolean', aliases: '-l', default: false, desc: 'operate on local branches (merged from remote)'
14
- option :merged, type: 'boolean', aliases: '-m', default: false, desc: 'only display branches that have been merged'
15
- option :pattern, type: 'string', aliases: '-p', default: '*XAP*', desc: 'specify a pattern for listing branches'
11
+ desc "push", <<-EOS
12
+ Creates the testing branch from develop, merges selected feature branch(es) and pushes to the remote (this is the
13
+ default action). The name of the testing branch is 'testing' unless the -b option is supplied. The 'development' branch
14
+ name can be over-ridden using ENV vars - see the source documentation for details of ENV var support. For all
15
+ boolean options, the default is 'false' unless otherwise stated above.
16
+
17
+ EOS
18
+ option :branch, type: 'string', aliases: '-b', default: nil, desc: 'specify an over-ride for the testing branch'
19
+ option :local, type: 'boolean', aliases: '-l', default: false, desc: 'operate on local branches (merged from remote)'
20
+ option :merged, type: 'boolean', aliases: '-m', default: false, desc: 'only display branches that have been merged'
21
+ option :pattern, type: 'string', aliases: '-p', default: '*XAP*', desc: 'specify a pattern for listing feature branches'
22
+ option :skip, type: 'string', aliases: '-s', default: false, desc: 'skip feature branch selection; just push develop to testing'
16
23
  def push
17
24
  testing_branch = options[:branch] || Ding::TESTING_BRANCH.dup
25
+ develop_branch = Ding::DEVELOP_BRANCH.dup
18
26
 
19
- say "\nDing ding ding: let's merge one or more feature branches to #{testing_branch}:\n\n", :green
27
+ if options[:skip]
28
+ say "\nDing ding ding: let's push the development branch to #{testing_branch}:\n\n", :green
29
+ else
30
+ say "\nDing ding ding: let's merge one or more feature branches to #{testing_branch}:\n\n", :green
31
+ end
20
32
 
21
33
  repo = Ding::Git.new(options).tap do |r|
22
34
  if r.is_dirty?
23
35
  say "> Local repo is dirty, resetting state", :yellow
24
36
  r.reset_local_state
25
37
  end
26
-
27
- develop_branch = r.branch_in_context(Ding::DEVELOP_BRANCH.dup)
28
- r.checkout develop_branch
38
+ r.checkout r.branch_in_context(develop_branch)
29
39
 
30
40
  say "> Deleting #{testing_branch}", :green
31
41
  r.delete_branch(testing_branch)
@@ -34,30 +44,35 @@ module Ding
34
44
  r.update
35
45
  end
36
46
 
37
- branches = repo.remote_branches(options[:pattern])
38
- if branches.empty?
39
- say "\n --> No feature branches available to test, I'm out of here!\n\n", :red
40
- exit 1
47
+ unless options[:skip]
48
+ branches = repo.remote_branches(options[:pattern])
49
+ if branches.empty?
50
+ say "\n --> No feature branches available to test, I'm out of here!\n\n", :red
51
+ exit 1
52
+ end
53
+ feature_branches = ask_which_item(branches, "\nWhich feature branch should I use?", :multiple)
54
+ say "\n"
41
55
  end
42
- feature_branches = ask_which_item(branches, "\nWhich feature branch should I use?", :multiple)
43
56
 
44
- commit_parents = repo.commit_parents(testing_branch)
57
+ original_commit_parents = repo.commit_parents(testing_branch)
45
58
 
46
59
  repo.tap do |r|
47
- say "\n> Deleting any synched #{testing_branch}", :green
60
+ say "> Deleting any synched #{testing_branch}", :green
48
61
  r.delete_branch(testing_branch)
49
62
 
50
- say "> Creating #{testing_branch}", :green
63
+ say "> Creating #{testing_branch} from #{develop_branch}", :green
51
64
  r.create_branch(testing_branch)
52
65
 
53
- say "> Merging in selected feature #{feature_branches.count == 1 ? 'branch' : 'branches'}...", :green
54
- merge_errors = false
55
- feature_branches.each do |branch|
56
- if r.merge_branch(branch)
57
- say " ✓ #{branch}", :green
58
- else
59
- say " ✗ #{branch}", :red
60
- merge_errors = true
66
+ unless options[:skip]
67
+ say "> Merging in selected feature #{feature_branches.count == 1 ? 'branch' : 'branches'}...", :green
68
+ merge_errors = false
69
+ feature_branches.each do |branch|
70
+ if r.merge_branch(branch)
71
+ say " ✓ #{branch}", :green
72
+ else
73
+ say " ✗ #{branch}", :red
74
+ merge_errors = true
75
+ end
61
76
  end
62
77
  end
63
78
 
@@ -69,8 +84,10 @@ module Ding
69
84
  exit 1
70
85
  end
71
86
 
72
- if repo.commit_parents(testing_branch).sort == commit_parents.sort
73
- result = options[:verbose] ? ": #{commit_parents}" : ''
87
+ if original_commit_parents &&
88
+ (remote_commit_parents = repo.commit_parents(testing_branch)) &&
89
+ remote_commit_parents.sort == original_commit_parents.sort
90
+ result = options[:verbose] ? ": #{original_commit_parents}" : ''
74
91
  say "\n --> That did not alter the testing branch commit parents#{result}!\n", :yellow
75
92
  end
76
93
  end
@@ -154,7 +171,6 @@ module Ding
154
171
  # presents a list of choices and allows either a single or multiple selection
155
172
  # returns the selected choices in an array or exits if selection is invalid
156
173
  def ask_which_item(items, prompt, mode=:single)
157
- return Array(items.first) if items.size == 1
158
174
  str_format = "\n %#{items.count.to_s.size}s: %s"
159
175
  prompt << "\n > Enter a single selection, "
160
176
  prompt << "multiple selections separated by ',', 'A' for all, " if mode == :multiple
@@ -177,8 +193,8 @@ module Ding
177
193
  elsif answers[reply]
178
194
  answers.values_at(reply)
179
195
  elsif mode == :single
180
- say "\n --> That's not a valid selection, I'm out of here!\n\n", :red
181
- exit 1
196
+ say "\n --> That's not a valid selection, I'm out of here!\n\n", :red
197
+ exit 1
182
198
  elsif mode == :multiple && reply.upcase == 'A'
183
199
  answers.values
184
200
  elsif mode == :multiple && !replies.empty?
@@ -3,7 +3,11 @@ module Ding
3
3
  # NOTE: only for commands where we are interested in the effect
4
4
  # as unless verbose is turned on, stdout and stderr are suppressed
5
5
  def run_cmd(cmd)
6
- cmd << ' &>/dev/null ' unless self.options[:verbose]
6
+ if self.options[:verbose]
7
+ puts "$ #{cmd}"
8
+ else
9
+ cmd << ' &>/dev/null '
10
+ end
7
11
  system cmd
8
12
  end
9
13
  end
@@ -41,7 +41,8 @@ module Ding
41
41
  end
42
42
 
43
43
  def commit_parents(branch)
44
- %x(git rev-list --parents -n 1 #{remote_version(branch)}).split.drop(1)
44
+ remote_branch = remote_version(branch)
45
+ %x(git rev-list --parents -n 1 #{remote_branch}).split.drop(1) if branch_exists?(remote_branch)
45
46
  end
46
47
 
47
48
  def delete_branch(branch)
@@ -1,3 +1,3 @@
1
1
  module Ding
2
- VERSION = "1.2.5"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ding
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warren Bain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler