ninny 0.1.0

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
+ SHA256:
3
+ metadata.gz: 98df22f85f20dc7fc0e1ec43b249d444f2edcbba41224cff9db0372639f69f54
4
+ data.tar.gz: 7ec2ae2eed695245fe34db0ab14252701064aa0e63e06b97067cde32ee81926e
5
+ SHA512:
6
+ metadata.gz: 149cf910ec915e4b982b07942113c2395b1b98aa7cfa0595ae35e1de42969fd8f10095882b48b149df1dab6d7358e530768c5a6f5238128612b1bcf4719af762
7
+ data.tar.gz: af7f0eb676b7c65463eaa2cd8702786bd7bb85e9be0c324ecd3fe0c0952ae58d743b846a74756b4b05c7f95ccbb6714c36eb5e2eb4276f34deecf027740c0549
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ .byebug_history
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+
14
+ # ninny configs
15
+ .ninny.yml*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ ninny
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.3
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at carl.allen@dispatchwithus.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ninny.gemspec
6
+ gem 'tty'
7
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ninny (0.1.0)
5
+ git (~> 1.5.0)
6
+ gitlab (~> 4.11.0)
7
+ pastel (~> 0.7.2)
8
+ thor (~> 0.20.0)
9
+ tty-box (~> 0.3.0)
10
+ tty-color (~> 0.4)
11
+ tty-command (~> 0.8.0)
12
+ tty-config (~> 0.3.0)
13
+ tty-prompt (~> 0.18.0)
14
+
15
+ GEM
16
+ remote: https://rubygems.org/
17
+ specs:
18
+ byebug (11.0.1)
19
+ diff-lcs (1.3)
20
+ equatable (0.5.0)
21
+ git (1.5.0)
22
+ gitlab (4.11.0)
23
+ httparty (~> 0.14, >= 0.14.0)
24
+ terminal-table (~> 1.5, >= 1.5.1)
25
+ httparty (0.17.0)
26
+ mime-types (~> 3.0)
27
+ multi_xml (>= 0.5.2)
28
+ kramdown (1.16.2)
29
+ mime-types (3.2.2)
30
+ mime-types-data (~> 3.2015)
31
+ mime-types-data (3.2019.0331)
32
+ multi_xml (0.6.0)
33
+ necromancer (0.4.0)
34
+ pastel (0.7.2)
35
+ equatable (~> 0.5.0)
36
+ tty-color (~> 0.4.0)
37
+ rake (10.5.0)
38
+ rouge (3.3.0)
39
+ rspec (3.8.0)
40
+ rspec-core (~> 3.8.0)
41
+ rspec-expectations (~> 3.8.0)
42
+ rspec-mocks (~> 3.8.0)
43
+ rspec-core (3.8.0)
44
+ rspec-support (~> 3.8.0)
45
+ rspec-expectations (3.8.3)
46
+ diff-lcs (>= 1.2.0, < 2.0)
47
+ rspec-support (~> 3.8.0)
48
+ rspec-mocks (3.8.0)
49
+ diff-lcs (>= 1.2.0, < 2.0)
50
+ rspec-support (~> 3.8.0)
51
+ rspec-support (3.8.0)
52
+ strings (0.1.5)
53
+ strings-ansi (~> 0.1)
54
+ unicode-display_width (~> 1.5)
55
+ unicode_utils (~> 1.4)
56
+ strings-ansi (0.1.0)
57
+ terminal-table (1.8.0)
58
+ unicode-display_width (~> 1.1, >= 1.1.1)
59
+ thor (0.20.3)
60
+ timers (4.3.0)
61
+ tty (0.9.1)
62
+ bundler (~> 1.16, < 2.0)
63
+ equatable (~> 0.5)
64
+ pastel (~> 0.7.2)
65
+ thor (~> 0.20.0)
66
+ tty-box (~> 0.3.0)
67
+ tty-color (~> 0.4)
68
+ tty-command (~> 0.8.0)
69
+ tty-config (~> 0.3.0)
70
+ tty-cursor (~> 0.6)
71
+ tty-editor (~> 0.5.0)
72
+ tty-file (~> 0.7.0)
73
+ tty-font (~> 0.2.0)
74
+ tty-markdown (~> 0.5.0)
75
+ tty-pager (~> 0.12.0)
76
+ tty-pie (~> 0.1.0)
77
+ tty-platform (~> 0.2.0)
78
+ tty-progressbar (~> 0.16.0)
79
+ tty-prompt (~> 0.18.0)
80
+ tty-screen (~> 0.6)
81
+ tty-spinner (~> 0.9.0)
82
+ tty-table (~> 0.10.0)
83
+ tty-tree (~> 0.2.0)
84
+ tty-which (~> 0.4)
85
+ tty-box (0.3.0)
86
+ pastel (~> 0.7.2)
87
+ strings (~> 0.1.4)
88
+ tty-cursor (~> 0.6.0)
89
+ tty-color (0.4.3)
90
+ tty-command (0.8.2)
91
+ pastel (~> 0.7.0)
92
+ tty-config (0.3.1)
93
+ tty-cursor (0.6.1)
94
+ tty-editor (0.5.0)
95
+ tty-prompt (~> 0.18)
96
+ tty-which (~> 0.4)
97
+ tty-file (0.7.1)
98
+ diff-lcs (~> 1.3)
99
+ pastel (~> 0.7.2)
100
+ tty-prompt (~> 0.18)
101
+ tty-font (0.2.0)
102
+ tty-markdown (0.5.1)
103
+ kramdown (~> 1.16.2)
104
+ pastel (~> 0.7.2)
105
+ rouge (~> 3.3)
106
+ strings (~> 0.1.4)
107
+ tty-color (~> 0.4)
108
+ tty-screen (~> 0.6)
109
+ tty-pager (0.12.1)
110
+ strings (~> 0.1.4)
111
+ tty-screen (~> 0.6)
112
+ tty-which (~> 0.4)
113
+ tty-pie (0.1.0)
114
+ pastel (~> 0.7.2)
115
+ tty-cursor (~> 0.6.0)
116
+ tty-platform (0.2.0)
117
+ tty-progressbar (0.16.0)
118
+ strings-ansi (~> 0.1.0)
119
+ tty-cursor (~> 0.6.0)
120
+ tty-screen (~> 0.6.4)
121
+ unicode-display_width (~> 1.3)
122
+ tty-prompt (0.18.1)
123
+ necromancer (~> 0.4.0)
124
+ pastel (~> 0.7.0)
125
+ timers (~> 4.0)
126
+ tty-cursor (~> 0.6.0)
127
+ tty-reader (~> 0.5.0)
128
+ tty-reader (0.5.0)
129
+ tty-cursor (~> 0.6.0)
130
+ tty-screen (~> 0.6.4)
131
+ wisper (~> 2.0.0)
132
+ tty-screen (0.6.5)
133
+ tty-spinner (0.9.0)
134
+ tty-cursor (~> 0.6.0)
135
+ tty-table (0.10.0)
136
+ equatable (~> 0.5.0)
137
+ necromancer (~> 0.4.0)
138
+ pastel (~> 0.7.2)
139
+ strings (~> 0.1.0)
140
+ tty-screen (~> 0.6.4)
141
+ tty-tree (0.2.0)
142
+ tty-which (0.4.1)
143
+ unicode-display_width (1.6.0)
144
+ unicode_utils (1.4.0)
145
+ wisper (2.0.0)
146
+
147
+ PLATFORMS
148
+ ruby
149
+
150
+ DEPENDENCIES
151
+ bundler (~> 1.17)
152
+ byebug
153
+ ninny!
154
+ rake (~> 10.0)
155
+ rspec (~> 3.0)
156
+ tty
157
+
158
+ BUNDLED WITH
159
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Carl Allen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Ninny
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ninny`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ninny'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ninny
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ninny. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Ninny project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ninny/blob/master/CODE_OF_CONDUCT.md).
40
+
41
+ ## Copyright
42
+
43
+ Copyright (c) 2019 Carl Allen. See [MIT License](LICENSE.txt) for further details.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ninny"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/ninny ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ lib_path = File.expand_path('../lib', __dir__)
4
+ $:.unshift(lib_path) if !$:.include?(lib_path)
5
+ require 'ninny'
6
+ require 'ninny/cli'
7
+
8
+ Signal.trap('INT') do
9
+ warn("\n#{caller.join("\n")}: interrupted")
10
+ exit(1)
11
+ end
12
+
13
+ begin
14
+ Ninny::CLI.start
15
+ rescue Ninny::CLI::Error => err
16
+ puts "ERROR: #{err.message}"
17
+ exit 1
18
+ end
data/lib/ninny/cli.rb ADDED
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'thor'
4
+
5
+ module Ninny
6
+ # Handle the application command line parsing
7
+ # and the dispatch to various command objects
8
+ #
9
+ # @api public
10
+ class CLI < Thor
11
+ # Error raised by this runner
12
+ Error = Class.new(StandardError)
13
+
14
+ desc 'version', 'ninny version'
15
+ def version
16
+ require_relative 'version'
17
+ puts "v#{Ninny::VERSION}"
18
+ end
19
+ map %w(--version -v) => :version
20
+
21
+ desc 'staging_branch', 'Returns the current staging branch'
22
+ method_option :help, aliases: '-h', type: :boolean,
23
+ desc: 'Display usage information'
24
+ def staging_branch(*)
25
+ if options[:help]
26
+ invoke :help, ['staging_branch']
27
+ else
28
+ require_relative 'commands/staging_branch'
29
+ Ninny::Commands::StagingBranch.new(options).execute
30
+ end
31
+ end
32
+
33
+ desc 'stage_up [PULL_REQUEST_ID]', 'Merges PR/MR into the staging branch'
34
+ method_option :help, aliases: '-h', type: :boolean,
35
+ desc: 'Display usage information'
36
+ def stage_up(pull_request_id = nil)
37
+ if options[:help]
38
+ invoke :help, ['stage_up']
39
+ else
40
+ require_relative 'commands/stage_up'
41
+ Ninny::Commands::StageUp.new(pull_request_id, options).execute
42
+ end
43
+ end
44
+
45
+ desc 'new_staging', 'Create a new staging branch'
46
+ method_option :help, aliases: '-h', type: :boolean,
47
+ desc: 'Display usage information'
48
+ method_option :delete_old_branches, aliases: ['-d'], type: :boolean,
49
+ desc: "Should old staging branches be deleted?"
50
+
51
+ def new_staging(*)
52
+ if options[:help]
53
+ invoke :help, ['new_staging']
54
+ else
55
+ require_relative 'commands/new_staging'
56
+ Ninny::Commands::NewStaging.new(options).execute
57
+ end
58
+ end
59
+
60
+ desc 'setup', 'Interactively setup configuration'
61
+ method_option :help, aliases: '-h', type: :boolean,
62
+ desc: 'Display usage information'
63
+ def setup(*)
64
+ if options[:help]
65
+ invoke :help, ['setup']
66
+ else
67
+ require_relative 'commands/setup'
68
+ Ninny::Commands::Setup.new(options).execute
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ninny
4
+ class Command
5
+ extend Forwardable
6
+
7
+ def_delegators :command, :run
8
+
9
+ # Execute this command
10
+ #
11
+ # @api public
12
+ def execute(*)
13
+ raise(
14
+ NotImplementedError,
15
+ "#{self.class}##{__method__} must be implemented"
16
+ )
17
+ end
18
+
19
+ # The external commands runner
20
+ #
21
+ # @see http://www.rubydoc.info/gems/tty-command
22
+ #
23
+ # @api public
24
+ def command(**options)
25
+ require 'tty-command'
26
+ TTY::Command.new(options)
27
+ end
28
+
29
+ # The cursor movement
30
+ #
31
+ # @see http://www.rubydoc.info/gems/tty-cursor
32
+ #
33
+ # @api public
34
+ def cursor
35
+ require 'tty-cursor'
36
+ TTY::Cursor
37
+ end
38
+
39
+ # Open a file or text in the user's preferred editor
40
+ #
41
+ # @see http://www.rubydoc.info/gems/tty-editor
42
+ #
43
+ # @api public
44
+ def editor
45
+ require 'tty-editor'
46
+ TTY::Editor
47
+ end
48
+
49
+ # File manipulation utility methods
50
+ #
51
+ # @see http://www.rubydoc.info/gems/tty-file
52
+ #
53
+ # @api public
54
+ def generator
55
+ require 'tty-file'
56
+ TTY::File
57
+ end
58
+
59
+ # Terminal output paging
60
+ #
61
+ # @see http://www.rubydoc.info/gems/tty-pager
62
+ #
63
+ # @api public
64
+ def pager(**options)
65
+ require 'tty-pager'
66
+ TTY::Pager.new(options)
67
+ end
68
+
69
+ # Terminal platform and OS properties
70
+ #
71
+ # @see http://www.rubydoc.info/gems/tty-pager
72
+ #
73
+ # @api public
74
+ def platform
75
+ require 'tty-platform'
76
+ TTY::Platform.new
77
+ end
78
+
79
+ # The interactive prompt
80
+ #
81
+ # @see http://www.rubydoc.info/gems/tty-prompt
82
+ #
83
+ # @api public
84
+ def prompt(**options)
85
+ require 'tty-prompt'
86
+ TTY::Prompt.new(options)
87
+ end
88
+
89
+ # Get terminal screen properties
90
+ #
91
+ # @see http://www.rubydoc.info/gems/tty-screen
92
+ #
93
+ # @api public
94
+ def screen
95
+ require 'tty-screen'
96
+ TTY::Screen
97
+ end
98
+
99
+ # The unix which utility
100
+ #
101
+ # @see http://www.rubydoc.info/gems/tty-which
102
+ #
103
+ # @api public
104
+ def which(*args)
105
+ require 'tty-which'
106
+ TTY::Which.which(*args)
107
+ end
108
+
109
+ # Check if executable exists
110
+ #
111
+ # @see http://www.rubydoc.info/gems/tty-which
112
+ #
113
+ # @api public
114
+ def exec_exist?(*args)
115
+ require 'tty-which'
116
+ TTY::Which.exist?(*args)
117
+ end
118
+ end
119
+ end
@@ -0,0 +1 @@
1
+ #
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ninny
4
+ module Commands
5
+ class CreateDatedBranch < Ninny::Command
6
+ attr_reader :branch_type, :should_delete_old_branches
7
+ def initialize(options)
8
+ @branch_type = options[:branch_type] || Git::STAGING_PREFIX
9
+ @should_delete_old_branches = options[:delete_old_branches]
10
+ end
11
+
12
+ def execute(input: $stdin, output: $stdout)
13
+ create_branch
14
+ delete_old_branches
15
+ output.puts "#{branch_name} created"
16
+ end
17
+
18
+ # Public: Create the desired branch
19
+ def create_branch
20
+ Ninny.git.new_branch(branch_name, Ninny.project_config.deploy_branch)
21
+ end
22
+
23
+ # Public: The date suffix to append to the branch name
24
+ def date_suffix
25
+ Date.today.strftime("%Y.%m.%d")
26
+ end
27
+
28
+ # Public: The name of the branch to create
29
+ def branch_name
30
+ with_branch_type do
31
+ "#{branch_type}.#{date_suffix}"
32
+ end
33
+ end
34
+
35
+ # Public: If necessary, and if user opts to, delete old branches of its type
36
+ def delete_old_branches
37
+ return unless extra_branches.any?
38
+ should_delete = should_delete_old_branches || prompt.yes?("Do you want to delete the old #{branch_type} branch(es)? (#{extra_branches.join(", ")})")
39
+
40
+ if should_delete
41
+ extra_branches.each do |extra|
42
+ Ninny.git.delete_branch(extra)
43
+ end
44
+ end
45
+ end
46
+
47
+ # Public: The list of extra branches that exist after creating the new branch
48
+ #
49
+ # Returns an Array of Strings of the branch names
50
+ def extra_branches
51
+ with_branch_type do
52
+ Ninny.git.branches_for(branch_type).select{ |branch| branch.name != branch_name }
53
+ end
54
+ end
55
+
56
+ def with_branch_type(&block)
57
+ case branch_type
58
+ when Git::DEPLOYABLE_PREFIX, Git::STAGING_PREFIX, Git::QAREADY_PREFIX
59
+ yield
60
+ else
61
+ raise InvalidBranchType, "'#{branch_type}' is not a valid branch type"
62
+ end
63
+ end
64
+ end
65
+ end
66
+ InvalidBranchType = Class.new(StandardError)
67
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ninny
4
+ module Commands
5
+ class NewStaging < CreateDatedBranch
6
+ def initialize(options)
7
+ super
8
+ @branch_type = Git::STAGING_PREFIX
9
+ end
10
+ end
11
+ end
12
+ end