thegarage-gitx 2.0.3 → 2.0.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0eea3b7dfcd17fef52f113c503608c7db7ad81d
|
4
|
+
data.tar.gz: 04eadf25b646e3aaff99d96e64c3adf1617b6df7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea835e6b0f8984ef7ce84c487a67d82ca47220853b1a25b548e21b04e132451bfd575b887730f50b9cc8e26c23ad57d171f8c5a3e8578f5cda4e9860129f44a
|
7
|
+
data.tar.gz: cb1ca449eb9a0923b03f10ee20c83d2fff59001df18ef50c7a6137af194256956884c17db8137931bf3b6c0821465cabc91da9bd470508b841b10c67e8e1a793
|
@@ -7,6 +7,7 @@ module Thegarage
|
|
7
7
|
module Cli
|
8
8
|
class StartCommand < BaseCommand
|
9
9
|
EXAMPLE_BRANCH_NAMES = %w( api-fix-invalid-auth desktop-cleanup-avatar-markup share-form-add-edit-link )
|
10
|
+
VALID_BRANCH_NAME_REGEX = /^[A-Za-z0-9\-_]+$/
|
10
11
|
|
11
12
|
desc 'start', 'start a new git branch with latest changes from master'
|
12
13
|
def start(branch_name = nil)
|
@@ -14,16 +15,21 @@ module Thegarage
|
|
14
15
|
branch_name = ask("What would you like to name your branch? (ex: #{EXAMPLE_BRANCH_NAMES.sample})")
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
+
checkout_branch Thegarage::Gitx::BASE_BRANCH
|
18
19
|
run_cmd 'git pull'
|
19
|
-
|
20
|
+
repo.create_branch branch_name, 'master'
|
21
|
+
checkout_branch branch_name
|
20
22
|
end
|
21
23
|
|
22
24
|
private
|
23
25
|
|
24
26
|
def valid_new_branch_name?(branch)
|
25
|
-
|
26
|
-
branch =~
|
27
|
+
return false if remote_branches.include?(branch)
|
28
|
+
branch =~ VALID_BRANCH_NAME_REGEX
|
29
|
+
end
|
30
|
+
|
31
|
+
def remote_branches
|
32
|
+
@remote_branches ||= Rugged::Branch.each_name(repo, :remote).to_a.map { |branch| branch.split('/').last }
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -10,18 +10,15 @@ describe Thegarage::Gitx::Cli::StartCommand do
|
|
10
10
|
}
|
11
11
|
end
|
12
12
|
let(:cli) { Thegarage::Gitx::Cli::StartCommand.new(args, options, config) }
|
13
|
-
let(:
|
14
|
-
|
15
|
-
before do
|
16
|
-
allow(cli).to receive(:current_branch).and_return(branch)
|
17
|
-
end
|
13
|
+
let(:repo) { cli.send(:repo) }
|
18
14
|
|
19
15
|
describe '#start' do
|
20
16
|
context 'when user inputs branch that is valid' do
|
21
17
|
before do
|
22
|
-
expect(cli).to receive(:
|
18
|
+
expect(cli).to receive(:checkout_branch).with('master').ordered
|
23
19
|
expect(cli).to receive(:run_cmd).with('git pull').ordered
|
24
|
-
expect(
|
20
|
+
expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
|
21
|
+
expect(cli).to receive(:checkout_branch).with('new-branch').ordered
|
25
22
|
|
26
23
|
cli.start 'new-branch'
|
27
24
|
end
|
@@ -31,11 +28,12 @@ describe Thegarage::Gitx::Cli::StartCommand do
|
|
31
28
|
end
|
32
29
|
context 'when user does not input a branch name' do
|
33
30
|
before do
|
34
|
-
expect(cli).to receive(:ask).and_return('
|
31
|
+
expect(cli).to receive(:ask).and_return('new-branch')
|
35
32
|
|
36
|
-
expect(cli).to receive(:
|
33
|
+
expect(cli).to receive(:checkout_branch).with('master').ordered
|
37
34
|
expect(cli).to receive(:run_cmd).with('git pull').ordered
|
38
|
-
expect(
|
35
|
+
expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
|
36
|
+
expect(cli).to receive(:checkout_branch).with('new-branch').ordered
|
39
37
|
|
40
38
|
cli.start
|
41
39
|
end
|
@@ -45,11 +43,12 @@ describe Thegarage::Gitx::Cli::StartCommand do
|
|
45
43
|
end
|
46
44
|
context 'when user inputs an invalid branch name' do
|
47
45
|
before do
|
48
|
-
expect(cli).to receive(:ask).and_return('
|
46
|
+
expect(cli).to receive(:ask).and_return('new-branch')
|
49
47
|
|
50
|
-
expect(cli).to receive(:
|
48
|
+
expect(cli).to receive(:checkout_branch).with('master').ordered
|
51
49
|
expect(cli).to receive(:run_cmd).with('git pull').ordered
|
52
|
-
expect(
|
50
|
+
expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
|
51
|
+
expect(cli).to receive(:checkout_branch).with('new-branch').ordered
|
53
52
|
|
54
53
|
cli.start 'a bad_branch-name?'
|
55
54
|
end
|
@@ -57,5 +56,20 @@ describe Thegarage::Gitx::Cli::StartCommand do
|
|
57
56
|
should meet_expectations
|
58
57
|
end
|
59
58
|
end
|
59
|
+
context 'when branch already exists in remote repo' do
|
60
|
+
before do
|
61
|
+
expect(cli).to receive(:ask).and_return('new-branch')
|
62
|
+
|
63
|
+
expect(cli).to receive(:checkout_branch).with('master').ordered
|
64
|
+
expect(cli).to receive(:run_cmd).with('git pull').ordered
|
65
|
+
expect(repo).to receive(:create_branch).with('new-branch', 'master').ordered
|
66
|
+
expect(cli).to receive(:checkout_branch).with('new-branch').ordered
|
67
|
+
|
68
|
+
cli.start 'master'
|
69
|
+
end
|
70
|
+
it 'prompts user to enter a new branch name' do
|
71
|
+
should meet_expectations
|
72
|
+
end
|
73
|
+
end
|
60
74
|
end
|
61
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thegarage-gitx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Sonnek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|