Class: Trop::InfoGit::GitProject

Inherits:
Object
  • Object
show all
Defined in:
lib/trop/infogit.rb

Class Method Summary collapse

Class Method Details

.commit_idObject



42
43
44
45
# File 'lib/trop/infogit.rb', line 42

def self.commit_id
  commit_id = `git show --format='%H' -q`
  return commit_id
end

.project_git_info(projectdir = '.') ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/trop/infogit.rb', line 29

def self.project_git_info(projectdir = '.')
  Dir.chdir(File.absolute_path(projectdir)) do
    @project_git_repo = `git config --get remote.origin.url`.chomp
    @project_git_name = @project_git_repo.to_s.split('/').last.gsub(/.git$/, '') unless @project_git_repo.empty?

    @project_username = `git config --get user.name`.chomp
    @project_useremail = `git config --get user.email`.chomp
    puts 'Project repo: #{@project_git_repo}'.blue if Sh.verbose?

    return @project_git_name, @project_git_repo, @project_username, @project_useremail
  end
end