Class: Historian::Git

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

Defined Under Namespace

Classes: Hooker

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, history) ⇒ Git

Returns a new instance of Git.



96
97
98
99
# File 'lib/historian/git.rb', line 96

def initialize(dir, history)
  @repo_directory = dir
  @history = history
end

Instance Attribute Details

#historyObject (readonly)

Returns the value of attribute history.



90
91
92
# File 'lib/historian/git.rb', line 90

def history
  @history
end

#repo_directoryObject (readonly)

Returns the value of attribute repo_directory.



90
91
92
# File 'lib/historian/git.rb', line 90

def repo_directory
  @repo_directory
end

Instance Method Details

#bundle_history_fileObject



92
93
94
# File 'lib/historian/git.rb', line 92

def bundle_history_file
  amend_history_changes
end

#install_hook(hook) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/historian/git.rb', line 101

def install_hook(hook)
  hook = Hooker.new(repo_directory, hook)
  if hook.other_git_hook_exists?
    hook.preserve_original
    hook.install
    :adapted
  elsif !hook.installed?
    hook.install
    :created
  else
    hook.update
    :exists
  end
end

#tag_releaseObject



116
117
118
119
120
121
122
123
124
# File 'lib/historian/git.rb', line 116

def tag_release
  commit_history_changes if history_dirty?
  ensure_history_has_release
  Tempfile.open("historian") do |file|
    file.puts commit_message_for_tag
    file.flush
    git "tag", "-a", tag, "-F", file.path
  end
end