Module: Gith::Git

Included in:
Deliver, Deploy, Discuss, Finish, Start
Defined in:
lib/gith/adapters/git.rb

Instance Method Summary collapse

Instance Method Details

#branch_name(story) ⇒ Object



16
17
18
19
# File 'lib/gith/adapters/git.rb', line 16

def branch_name(story)
  name = story.name.split.first(6).join(' ').gsub(/\W/, '-').gsub(/--/, '-')
  "#{story.story_type}/#{name.downcase}-#{story.id}"
end

#commit_allObject



33
34
35
# File 'lib/gith/adapters/git.rb', line 33

def commit_all
  `git commit -a`
end

#create_branch(story) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/gith/adapters/git.rb', line 4

def create_branch(story)
  name = branch_name(story)

  unless yes_or_no "Would you like to name the branch #{name.color(:cyan)}?"
    name = asks "What would you like to name the branch?"
  end

  notify "Creating branch #{name}"

  `git checkout -b #{name}`
end

#current_branchObject



21
22
23
# File 'lib/gith/adapters/git.rb', line 21

def current_branch
  `git rev-parse --abbrev-ref HEAD`.chomp!
end

#current_story_idObject



25
26
27
# File 'lib/gith/adapters/git.rb', line 25

def current_story_id
  current_branch.match(/\d+/).to_s
end

#push_branch(branch) ⇒ Object



37
38
39
# File 'lib/gith/adapters/git.rb', line 37

def push_branch(branch)
  `git push origin #{branch}`
end

#push_current_branchObject



41
42
43
# File 'lib/gith/adapters/git.rb', line 41

def push_current_branch
  push_branch(current_branch)
end

#unstaged_changes?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/gith/adapters/git.rb', line 29

def unstaged_changes?
  `git status -s`.chomp.length > 0
end