class VCLog::Adapters::Git
GIT Adapter.
Constants
- GIT_COMMIT_MARKER
- GIT_FIELD_MARKER
- RUBY_COMMIT_MARKER
- RUBY_FIELD_MARKER
Public Instance Methods
email()
click to toggle source
Email address of developer.
# File lib/vclog/adapters/git.rb, line 135 def email @email ||= `git config user.email`.strip end
extract_changes()
click to toggle source
Collect changes, i.e. commits.
# File lib/vclog/adapters/git.rb, line 18 def extract_changes list = [] command = 'git log --name-only --pretty=format:"' + GIT_COMMIT_MARKER + '%ci' + GIT_FIELD_MARKER + '%aN' + GIT_FIELD_MARKER + '%H' + GIT_FIELD_MARKER + '%s%n%n%b' + GIT_FIELD_MARKER + '"' changes = `#{command}`.split(RUBY_COMMIT_MARKER) changes.shift # throw the first (empty) entry away changes.each do |entry| date, who, id, msg, files = entry.split(RUBY_FIELD_MARKER) date = Time.parse(date) files = files.split("\n") list << Change.new(:id=>id, :date=>date, :who=>who, :msg=>msg, :files=>files) end return list end
repository()
click to toggle source
# File lib/vclog/adapters/git.rb, line 140 def repository @repository ||= `git config remote.origin.url`.strip end
tag(ref, label, date, message)
click to toggle source
Create a tag for the given commit reference.
# File lib/vclog/adapters/git.rb, line 147 def tag(ref, label, date, message) file = tempfile("message", message) date = date.strftime('%Y-%m-%d 23:59') unless String===date cmd = %[GIT_AUTHOR_DATE='#{date}' GIT_COMMITTER_DATE='#{date}' git tag -a -F '#{file}' #{label} #{ref}] puts cmd if $DEBUG `#{cmd}` unless $DRYRUN end
user()
click to toggle source
User name of developer.
# File lib/vclog/adapters/git.rb, line 130 def user @user ||= `git config user.name`.strip end
Private Instance Methods
git_show(ref)
click to toggle source
# File lib/vclog/adapters/git.rb, line 161 def git_show(ref) command = 'git show ' + ref.to_s + ' --name-only --pretty=format:"' + '%ci' + GIT_FIELD_MARKER + '%cn' + GIT_FIELD_MARKER + '%ce' + GIT_FIELD_MARKER + '%H' + GIT_FIELD_MARKER + '%s%n%n%b' + GIT_FIELD_MARKER + '"' entry = `#{command}` date, who, email, id, msg, files = entry.split(RUBY_FIELD_MARKER) who = who + ' ' + email date = Time.parse(date) files = files.split("\n") return { :date=>date, :who=>who, :id=>id, :message=>msg, :files=>files } end