Class: Opsk::CommitGit

Inherits:
Object
  • Object
show all
Defined in:
lib/opskeleton/uncommited.rb

Instance Method Summary collapse

Constructor Details

#initialize(d, options, thor) ⇒ CommitGit



5
6
7
8
9
# File 'lib/opskeleton/uncommited.rb', line 5

def initialize(d,options,thor)
  @g = Git.init(d)
  @options = options
  @thor = thor
end

Instance Method Details

#changed?Boolean



11
12
13
# File 'lib/opskeleton/uncommited.rb', line 11

def changed?
  @g.status.changed.keys.length > 0
end

#master_commit(d) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/opskeleton/uncommited.rb', line 25

def master_commit(d)
  resp = @thor.yes? "Commit the changes under #{d}? (y/n)" unless @options['all']
  if(@options['all'] or resp)
    @g.checkout('master')
    if @options['message']
 @g.commit_all(@options['message']) 
    else 
 @thor.say 'Commit message:'
 @g.commit_all(STDIN.gets.chomp) 
    end
  end

end

#reportObject



15
16
17
18
19
20
21
22
23
# File 'lib/opskeleton/uncommited.rb', line 15

def report
  i(changed added untracked).each do |state|
    @thor.say "#{state} files:\n\n"
    @g.status.send(state).each do |k,v|
 @thor.say "- #{k}"
    end
    @thor.say "\n"
  end
end