Class: GitFlower::GitService
- Inherits:
-
Object
- Object
- GitFlower::GitService
- Defined in:
- lib/git_flower/git_service.rb
Instance Method Summary collapse
-
#initialize(repository:) ⇒ GitService
constructor
A new instance of GitService.
- #start_branch(name:, id:, type:) ⇒ Object
- #validate_for_feature! ⇒ Object
- #validate_for_hotfix! ⇒ Object
Constructor Details
#initialize(repository:) ⇒ GitService
Returns a new instance of GitService.
10 11 12 |
# File 'lib/git_flower/git_service.rb', line 10 def initialize(repository:) @repository = repository end |
Instance Method Details
#start_branch(name:, id:, type:) ⇒ Object
14 15 16 17 |
# File 'lib/git_flower/git_service.rb', line 14 def start_branch(name:, id:, type:) branch_name = GitFlower::Branch.new(name: name, id: id, type: type).name repository.checkout_branch(branch_name) end |
#validate_for_feature! ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/git_flower/git_service.rb', line 36 def validate_for_feature! puts "Checking for commited files" if repository.has_added_files? raise GitError, "Please commit or stash all added files." end puts "Checking if develop is up to date" if !repository.develop_up_to_date? raise GitError, "Please pull --rebase develop" end end |
#validate_for_hotfix! ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/git_flower/git_service.rb', line 19 def validate_for_hotfix! puts "Checking for commited files" if repository.has_added_files? raise GitError, "Please commit or stash all added files." end puts "Checking if master and develop are up to date" if !repository.master_up_to_date? || !repository.develop_up_to_date? raise GitError, "Please pull --rebase master and develop" end puts "Checking for existing hotfix branch" if repository.has_existing_branch_name?("hotfix") raise GitFlowError, "You already have an existing hotfix branch" end end |