Class: AmusingGit::GitRepository

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, config) ⇒ GitRepository

Returns a new instance of GitRepository.



5
6
7
8
# File 'lib/amusing_git/git/git_repository.rb', line 5

def initialize(dir, config)
  @dir = dir
  @hooks = config.hooks
end

Class Method Details

.git_repo?(dir) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/amusing_git/git/git_repository.rb', line 31

def self.git_repo? dir
  File.exists? "#{dir}/.git"
end

Instance Method Details

#configure_amusing_git!Object



18
19
20
21
22
23
# File 'lib/amusing_git/git/git_repository.rb', line 18

def configure_amusing_git!
  hooks.each do |hook|
    hook.create! unless hook.exists?
    hook.configure_amusing_git! unless hook.amusing?
  end
end

#create_hooks!Object



14
15
16
# File 'lib/amusing_git/git/git_repository.rb', line 14

def create_hooks!
  `mkdir -p .git/hooks`
end

#has_hooks?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/amusing_git/git/git_repository.rb', line 10

def has_hooks?
  File.exists? "#{@dir}/.git/hooks"
end

#remove_amusing_git!Object



25
26
27
28
29
# File 'lib/amusing_git/git/git_repository.rb', line 25

def remove_amusing_git!
  hooks.each do |hook|
    hook.remove_amusing_git! if hook.amusing?
  end
end