git_flower 0.1.3 → 0.2.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: 6f30c2286addf8b6234c28f4c6c6eb2735bc277c
4
- data.tar.gz: 97c03ad37b98adcd18a503b9f1bfaf824d9ff83f
3
+ metadata.gz: 19c0297fcd7615a932a0a3acec5ff4a2666a73ef
4
+ data.tar.gz: 79dbf666a97ab5ae0d05fe783b3cc23d04650433
5
5
  SHA512:
6
- metadata.gz: ea2a592614d095d47d5954fe5c26636f64502288bdc7e066342b2cc0f42fba4f7917ea45fffa4f9c7becc7a8924b44bdf00dbb8d0aa2226059dace66993f497b
7
- data.tar.gz: 81da16fa907d540b28cfce60493672afa5a805a5888a1924af9884413575e79113855a5d225f0148ea58d8d4b0e1d095c5c5eeaaf877319e5fc37e17f9b39651
6
+ metadata.gz: ed2a84fff3476ceabd56698396dc48f13dc6885ac4c518ff1ff2fc7cec0035eee48030a3b3b08621b859c6eda15ddc7585fc5f6faecba9ec69715ddc770ea9ef
7
+ data.tar.gz: 025cffe51830ccb074e114b772b71332f4251f1fd6d02fdc6097d570610ad01d4f26091b652ff9fe9a5f419c8c741f57f8992aaf254a8a608b9314a4d076649a
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_flower (0.1.3)
4
+ git_flower (0.2.0)
5
5
  activesupport (~> 5.1.2)
6
6
  faraday (~> 0.9.0)
7
7
  git (~> 1.3.0)
@@ -34,6 +34,7 @@ GEM
34
34
  docile (1.1.5)
35
35
  equalizer (0.0.11)
36
36
  excon (0.57.1)
37
+ fakefs (0.11.0)
37
38
  faraday (0.9.2)
38
39
  multipart-post (>= 1.2, < 3)
39
40
  faraday_middleware (0.11.0.1)
@@ -88,6 +89,7 @@ PLATFORMS
88
89
  DEPENDENCIES
89
90
  bundler (~> 1.15)
90
91
  byebug
92
+ fakefs (~> 0.11)
91
93
  git_flower!
92
94
  rake (~> 10.0)
93
95
  rspec (~> 3.0)
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "rspec", "~> 3.0"
29
29
  spec.add_development_dependency "byebug"
30
30
  spec.add_development_dependency "simplecov", "~>0.14"
31
+ spec.add_development_dependency "fakefs", "~>0.11"
31
32
 
32
33
  spec.add_dependency "git", "~> 1.3.0"
33
34
  spec.add_dependency "thor", "~> 0.19.4"
@@ -2,6 +2,7 @@ require "git_flower/version"
2
2
  require "git_flower/story"
3
3
  require "git_flower/feature"
4
4
  require "git_flower/hotfix"
5
+ require "git_flower/git_service"
5
6
  require "git_flower/git_repository"
6
7
  require "git_flower/pivotal_project"
7
8
  require "git_flower/feature-cli"
@@ -13,7 +13,9 @@ module GitFlower
13
13
  private
14
14
 
15
15
  def validate_git_repository!
16
- GitRepository.new(Dir.pwd).validate_for_feature!
16
+ GitService.
17
+ new(repository: GitFlower::GitRepository.new(Dir.pwd)).
18
+ validate_for_feature!
17
19
  end
18
20
 
19
21
  def create_feature!
@@ -1,8 +1,4 @@
1
1
  require 'git'
2
- require_relative 'branch'
3
-
4
- class GitError < StandardError; end
5
- class GitFlowError < StandardError; end
6
2
 
7
3
  module GitFlower
8
4
  class GitRepository
@@ -10,42 +6,18 @@ module GitFlower
10
6
  @repo = find_git_repo(path_to_repo)
11
7
  end
12
8
 
13
- def start_branch(name:, id:, type:)
14
- branch_name = GitFlower::Branch.new(name: name, id: id, type: type).name
15
- @repo.branch(branch_name).checkout
16
- end
17
-
18
- def validate_for_hotfix!
19
- puts "Checking for commited files"
20
- if has_added_files?
21
- raise GitError, "Please commit or stash all added files."
22
- end
23
-
24
- puts "Checking if master and develop are up to date"
25
- if !master_up_to_date? || !develop_up_to_date?
26
- raise GitError, "Please pull --rebase master and develop"
27
- end
28
-
29
- puts "Checking for existing hotfix branch"
30
- if has_existing_branch_name?("hotfix")
31
- raise GitFlowError, "You already have an existing hotfix branch"
9
+ def find_git_repo(initial_dir)
10
+ if Dir.exist?('.git')
11
+ Git.open(initial_dir)
12
+ else
13
+ raise GitError, "Please navigate to the root of your git repository to use this gem."
32
14
  end
33
15
  end
34
16
 
35
- def validate_for_feature!
36
- puts "Checking for commited files"
37
- if has_added_files?
38
- raise GitError, "Please commit or stash all added files."
39
- end
40
-
41
- puts "Checking if develop is up to date"
42
- if !develop_up_to_date?
43
- raise GitError, "Please pull --rebase develop"
44
- end
17
+ def checkout_branch(branch_name)
18
+ @repo.branch(branch_name).checkout
45
19
  end
46
20
 
47
- private
48
-
49
21
  def has_added_files?
50
22
  !@repo.status.added.empty?
51
23
  end
@@ -65,22 +37,5 @@ module GitFlower
65
37
  def branch_up_to_date?(branch_name)
66
38
  @repo.revparse(branch_name) == @repo.revparse("origin/#{branch_name}")
67
39
  end
68
-
69
- def no_git_repo_can_be_found
70
- !system 'git status'
71
- end
72
-
73
- def find_git_repo(initial_dir)
74
- if no_git_repo_can_be_found
75
- raise GitError
76
- end
77
-
78
- if Dir.exist?('.git')
79
- Git.open(initial_dir)
80
- else
81
- Dir.chdir('..')
82
- find_git_repo(Dir.pwd)
83
- end
84
- end
85
40
  end
86
41
  end
@@ -0,0 +1,52 @@
1
+ require 'git'
2
+ require_relative 'branch'
3
+ require_relative 'git_repository'
4
+
5
+ class GitError < StandardError; end
6
+ class GitFlowError < StandardError; end
7
+
8
+ module GitFlower
9
+ class GitService
10
+ def initialize(repository:)
11
+ @repository = repository
12
+ end
13
+
14
+ def start_branch(name:, id:, type:)
15
+ branch_name = GitFlower::Branch.new(name: name, id: id, type: type).name
16
+ repository.checkout_branch(branch_name)
17
+ end
18
+
19
+ def validate_for_hotfix!
20
+ puts "Checking for commited files"
21
+ if repository.has_added_files?
22
+ raise GitError, "Please commit or stash all added files."
23
+ end
24
+
25
+ puts "Checking if master and develop are up to date"
26
+ if !repository.master_up_to_date? || !repository.develop_up_to_date?
27
+ raise GitError, "Please pull --rebase master and develop"
28
+ end
29
+
30
+ puts "Checking for existing hotfix branch"
31
+ if repository.has_existing_branch_name?("hotfix")
32
+ raise GitFlowError, "You already have an existing hotfix branch"
33
+ end
34
+ end
35
+
36
+ def validate_for_feature!
37
+ puts "Checking for commited files"
38
+ if repository.has_added_files?
39
+ raise GitError, "Please commit or stash all added files."
40
+ end
41
+
42
+ puts "Checking if develop is up to date"
43
+ if !repository.develop_up_to_date?
44
+ raise GitError, "Please pull --rebase develop"
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ attr_reader :repository
51
+ end
52
+ end
@@ -13,7 +13,9 @@ module GitFlower
13
13
  private
14
14
 
15
15
  def validate_git_repository!
16
- GitRepository.new(Dir.pwd).validate_for_hotfix!
16
+ GitService.
17
+ new(repository: GitFlower::GitRepository.new(Dir.pwd)).
18
+ validate_for_hotfix!
17
19
  end
18
20
 
19
21
  def create_hotfix!
@@ -16,6 +16,10 @@ module GitFlower
16
16
  end
17
17
  end
18
18
 
19
+ private
20
+
21
+ attr_reader :project
22
+
19
23
  def create_hotfix(options)
20
24
  story_owner_ids = find_users(options[:owner_usernames]).map(&:id)
21
25
  project.create_story(name: options[:name],
@@ -35,10 +39,6 @@ module GitFlower
35
39
  owner_ids: story_owner_ids)
36
40
  end
37
41
 
38
- private
39
-
40
- attr_reader :project
41
-
42
42
  def find_users(owner_usernames)
43
43
  project.memberships.map(&:person).select do |person|
44
44
  owner_usernames.include? person.email.split("@").first
@@ -1,6 +1,7 @@
1
1
  require 'shellwords'
2
2
  require 'yaml'
3
3
  require 'active_support'
4
+ require_relative 'git_service'
4
5
  require_relative 'git_repository'
5
6
  require_relative 'pivotal_project'
6
7
 
@@ -24,8 +25,8 @@ module GitFlower
24
25
  puts "Your pivotal story is https://www.pivotaltracker.com/story/show/#{story.id}"
25
26
  puts "Creating #{type} branch for #{story_name}"
26
27
 
27
- GitRepository.
28
- new(Dir.pwd).
28
+ GitService.
29
+ new(repository: GitFlower::GitRepository.new(Dir.pwd)).
29
30
  start_branch(name: story_name, id: story.id, type: type)
30
31
  end
31
32
 
@@ -1,3 +1,3 @@
1
1
  module GitFlower
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_flower
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Wilkinson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-13 00:00:00.000000000 Z
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.14'
83
+ - !ruby/object:Gem::Dependency
84
+ name: fakefs
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.11'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.11'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: git
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -180,6 +194,7 @@ files:
180
194
  - lib/git_flower/feature-cli.rb
181
195
  - lib/git_flower/feature.rb
182
196
  - lib/git_flower/git_repository.rb
197
+ - lib/git_flower/git_service.rb
183
198
  - lib/git_flower/hotfix-cli.rb
184
199
  - lib/git_flower/hotfix.rb
185
200
  - lib/git_flower/pivotal_project.rb