ninny 0.1.14 → 0.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +18 -0
- data/lib/ninny/commands/create_dated_branch.rb +2 -1
- data/lib/ninny/git.rb +45 -8
- data/lib/ninny/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c01f0689e01c71df928ec993bf38c3be68321b1389ef4db7c1ca0c601d0fd02
|
4
|
+
data.tar.gz: 60d84b30dcfe5e8da077e12f59dac45085c94e10d6a060d5d44fa205bbd9196a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 051ef3ceebdc3934e5e2438c25020cc2b7ff8cb1c5428746005c0138658682c8934207fbddb605b03b7f7458ac79d018a56d380bfb8b971075e8c9229642b67a
|
7
|
+
data.tar.gz: 7f3cb4b1f7857bb0380de618016c3d17cd29f9dbdfec9a5d3c1ead4110adaa596a390afae4933b71ef5a9aeca8c9e464878d80c2233149b835bb2660e39d425d
|
data/.rubocop.yml
CHANGED
@@ -11,6 +11,10 @@ Gemspec/RequiredRubyVersion:
|
|
11
11
|
Style/Documentation:
|
12
12
|
Enabled: false
|
13
13
|
|
14
|
+
Layout/LineLength:
|
15
|
+
Exclude:
|
16
|
+
- spec/**/*
|
17
|
+
|
14
18
|
Lint/EmptyClass:
|
15
19
|
Enabled: false
|
16
20
|
|
@@ -20,8 +24,22 @@ Lint/EmptyBlock:
|
|
20
24
|
Lint/MissingSuper:
|
21
25
|
Enabled: false
|
22
26
|
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Enabled: true
|
29
|
+
Exclude:
|
30
|
+
- spec/**/*
|
31
|
+
- ninny.gemspec
|
32
|
+
|
23
33
|
Metrics/MethodLength:
|
24
34
|
Max: 15
|
25
35
|
|
36
|
+
Style/AccessModifierDeclarations:
|
37
|
+
EnforcedStyle: inline
|
38
|
+
|
39
|
+
Style/BlockDelimiters:
|
40
|
+
Enabled: true
|
41
|
+
Exclude:
|
42
|
+
- spec/**/*
|
43
|
+
|
26
44
|
Style/OptionalBooleanParameter:
|
27
45
|
Enabled: false
|
@@ -13,11 +13,12 @@ module Ninny
|
|
13
13
|
def execute(output: $stdout)
|
14
14
|
create_branch
|
15
15
|
delete_old_branches
|
16
|
-
output.puts "#{branch_name} created"
|
16
|
+
output.puts "Branch #{branch_name} successfully created."
|
17
17
|
end
|
18
18
|
|
19
19
|
# Public: Create the desired branch
|
20
20
|
def create_branch
|
21
|
+
prompt.say "Attempting to create branch #{branch_name}."
|
21
22
|
Ninny.git.new_branch(branch_name, Ninny.project_config.deploy_branch)
|
22
23
|
end
|
23
24
|
|
data/lib/ninny/git.rb
CHANGED
@@ -38,7 +38,7 @@ module Ninny
|
|
38
38
|
|
39
39
|
def merge(branch_name)
|
40
40
|
if_clean do
|
41
|
-
git.fetch
|
41
|
+
git.fetch('-p')
|
42
42
|
command 'merge', ['--no-ff', "origin/#{branch_name}"]
|
43
43
|
raise MergeFailed unless clean?
|
44
44
|
|
@@ -65,7 +65,7 @@ module Ninny
|
|
65
65
|
# branch_name - The name of the branch to check out
|
66
66
|
# do_after_pull - Should a pull be done after checkout?
|
67
67
|
def check_out(branch, do_after_pull = true)
|
68
|
-
git.fetch
|
68
|
+
git.fetch('-p')
|
69
69
|
git.checkout(branch)
|
70
70
|
pull if do_after_pull
|
71
71
|
raise CheckoutFailed, "Failed to check out '#{branch}'" unless current_branch.name == branch.name
|
@@ -84,11 +84,20 @@ module Ninny
|
|
84
84
|
# new_branch_name - The name of the branch to create
|
85
85
|
# source_branch_name - The name of the branch to branch from
|
86
86
|
def new_branch(new_branch_name, source_branch_name)
|
87
|
-
git.fetch
|
88
|
-
command('branch', ['--
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
git.fetch('-p')
|
88
|
+
remote_branches = command('branch', ['--remote'])
|
89
|
+
|
90
|
+
if remote_branches.include?("origin/#{new_branch_name}")
|
91
|
+
ask_to_recreate_branch(new_branch_name, source_branch_name)
|
92
|
+
else
|
93
|
+
create_branch(new_branch_name, source_branch_name)
|
94
|
+
end
|
95
|
+
rescue ::Git::GitExecuteError => e
|
96
|
+
if e.message.include?(':fatal: A branch named') && e.message.include?(' already exists')
|
97
|
+
puts "The local branch #{new_branch_name} already exists." \
|
98
|
+
' Please delete it manually and then run this command again.'
|
99
|
+
exit 1
|
100
|
+
end
|
92
101
|
end
|
93
102
|
|
94
103
|
# Public: Delete the given branch
|
@@ -98,13 +107,17 @@ module Ninny
|
|
98
107
|
branch = branch_name.is_a?(::Git::Branch) ? branch_name : git.branch(branch_name)
|
99
108
|
git.push('origin', ":#{branch}")
|
100
109
|
branch.delete
|
110
|
+
rescue ::Git::GitExecuteError => e
|
111
|
+
if e.message.include?(':error: branch') && e.message.include?(' not found.')
|
112
|
+
puts 'Could not delete local branch, but the remote branch was deleted.'
|
113
|
+
end
|
101
114
|
end
|
102
115
|
|
103
116
|
# Public: The list of branches on GitHub
|
104
117
|
#
|
105
118
|
# Returns an Array of Strings containing the branch names
|
106
119
|
def remote_branches
|
107
|
-
git.fetch
|
120
|
+
git.fetch('-p')
|
108
121
|
git.branches.remote.map { |branch| git.branch(branch.name) }.sort_by(&:name)
|
109
122
|
end
|
110
123
|
|
@@ -159,6 +172,30 @@ module Ninny
|
|
159
172
|
TTY::Prompt.new(options)
|
160
173
|
end
|
161
174
|
|
175
|
+
# Private: Ask the user if they wish to delete and recreate a branch
|
176
|
+
#
|
177
|
+
# new_branch_name: the name of the branch in question
|
178
|
+
# source_branch_name: the name of the branch the new branch is supposed to be based off of
|
179
|
+
private def ask_to_recreate_branch(new_branch_name, source_branch_name)
|
180
|
+
if prompt.yes?("The branch #{new_branch_name} already exists. Do you wish to delete and recreate?")
|
181
|
+
delete_branch(new_branch_name)
|
182
|
+
new_branch(new_branch_name, source_branch_name)
|
183
|
+
else
|
184
|
+
exit 1
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
# Private: Create a branch
|
189
|
+
#
|
190
|
+
# new_branch_name: the name of the branch in question
|
191
|
+
# source_branch_name: the name of the branch the new branch is supposed to be based off of
|
192
|
+
private def create_branch(new_branch_name, source_branch_name)
|
193
|
+
command('branch', ['--no-track', new_branch_name, "origin/#{source_branch_name}"])
|
194
|
+
new_branch = branch(new_branch_name)
|
195
|
+
new_branch.checkout
|
196
|
+
command('push', ['-u', 'origin', new_branch_name])
|
197
|
+
end
|
198
|
+
|
162
199
|
# Exceptions
|
163
200
|
CheckoutFailed = Class.new(StandardError)
|
164
201
|
NotOnBranch = Class.new(StandardError)
|
data/lib/ninny/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ninny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dispatch Engineers
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -325,7 +325,7 @@ homepage: https://github.com/dispatchinc/ninny
|
|
325
325
|
licenses:
|
326
326
|
- MIT
|
327
327
|
metadata: {}
|
328
|
-
post_install_message:
|
328
|
+
post_install_message:
|
329
329
|
rdoc_options: []
|
330
330
|
require_paths:
|
331
331
|
- lib
|
@@ -341,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
341
341
|
version: '0'
|
342
342
|
requirements: []
|
343
343
|
rubygems_version: 3.1.4
|
344
|
-
signing_key:
|
344
|
+
signing_key:
|
345
345
|
specification_version: 4
|
346
346
|
summary: 'ninny (n): an foolish person, see: git'
|
347
347
|
test_files: []
|