class RepoGit

Public Instance Methods

any_uncommited_changes?() click to toggle source
# File lib/punt/repo/repo_git.rb, line 3
def any_uncommited_changes?()
    return true if `git diff --numstat | wc -l`.strip != "0"
    return true if `git diff --cached --numstat | wc -l`.strip != "0"
    return true if `git ls-files --others --exclude-standard | wc -l`.strip != "0"
    return false
end
canonical_revision_name(revision_name, short: false) click to toggle source
# File lib/punt/repo/repo_git.rb, line 14
def canonical_revision_name(revision_name, short: false)
    return `git rev-parse --short --verify #{revision_name}`.strip if short
    return `git rev-parse --verify #{revision_name}`.strip
end
checkout_revision(revision_name, dry_run: false) click to toggle source
# File lib/punt/repo/repo_git.rb, line 19
def checkout_revision(revision_name, dry_run: false)
    puts "git checkout #{revision_name}" if dry_run
    `git checkout #{revision_name}` unless dry_run
end
current_revision_name(short: false) click to toggle source
# File lib/punt/repo/repo_git.rb, line 10
def current_revision_name(short: false)
    canonical_revision_name("HEAD", short: short)
end
restore_state(state, dry_run: false) click to toggle source
# File lib/punt/repo/repo_git.rb, line 31
def restore_state(state, dry_run: false)
    puts "git checkout #{state}" if dry_run
    `git checkout #{state}` unless dry_run
end
save_state() click to toggle source
# File lib/punt/repo/repo_git.rb, line 24
def save_state()
    current_branch = `git rev-parse --abbrev-ref HEAD`

    return current_revision_name if current_branch == "HEAD"
    return current_branch
end