Class: GitFlower::GitRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/git_flower/git_repository.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_to_repo) ⇒ GitRepository



9
10
11
# File 'lib/git_flower/git_repository.rb', line 9

def initialize(path_to_repo)
  @repo = find_git_repo(path_to_repo)
end

Instance Method Details

#start_branch(name:, id:, type:) ⇒ Object



13
14
15
16
# File 'lib/git_flower/git_repository.rb', line 13

def start_branch(name:, id:, type:)
  branch_name = GitFlower::Branch.new(name: name, id: id, type: type).name
  @repo.branch(branch_name).checkout
end

#validate_for_feature!Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/git_flower/git_repository.rb', line 35

def validate_for_feature!
  puts "Checking for commited files"
  if has_added_files?
    raise GitError, "Please commit or stash all added files."
  end

  puts "Checking if develop is up to date"
  if !develop_up_to_date?
    raise GitError, "Please pull --rebase develop"
  end
end

#validate_for_hotfix!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/git_flower/git_repository.rb', line 18

def validate_for_hotfix!
  puts "Checking for commited files"
  if has_added_files?
    raise GitError, "Please commit or stash all added files."
  end

  puts "Checking if master and develop are up to date"
  if !master_up_to_date? || !develop_up_to_date?
    raise GitError, "Please pull --rebase master and develop"
  end

  puts "Checking for existing hotfix branch"
  if has_existing_branch_name?("hotfix")
    raise GitFlowError, "You already have an existing hotfix branch"
  end
end