Class: Git

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

Class Method Summary collapse

Class Method Details

.amnesia_maxObject



14
15
16
17
18
19
20
21
# File 'lib/git-amnesia/git.rb', line 14

def self.amnesia_max
    count = `git config amnesia.count`.trim.to_i
    if $?.exitstatus == 0
        count
    else
        @amnesia_count_default
    end
end

.author_nameObject



23
24
25
# File 'lib/git-amnesia/git.rb', line 23

def self.author_name
    `git config user.name`.trim
end

.logs(repos) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/git-amnesia/git.rb', line 38

def self.logs(repos)
    logs = []
    repos.each do |repo|
    cmd = "cd '#{repo}' 2>/dev/null" +
        " && git log --max-count=#{Git.amnesia_max} --author='#{Git.author_name}'" +
        " --pretty=format:'%at::#{repo.basename}::%s' 2>/dev/null"
        log = `#{cmd}`
        if $?.exitstatus == 0
            logs += log.explode.map { |l| Log.new(l) }
        end
    end
    logs
end

.other_dirsObject



10
11
12
# File 'lib/git-amnesia/git.rb', line 10

def self.other_dirs
    `git config dir.others | envsubst`.split_dirs.explode
end

.reposObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/git-amnesia/git.rb', line 27

def self.repos
    workspace = Git.workspace
    repos = Git.other_dirs
    if !workspace.empty?
        repos += `ls #{workspace}`.explode.map do |r|
            r.prepend("#{workspace}/")
        end
    end
    repos
end

.workspaceObject



6
7
8
# File 'lib/git-amnesia/git.rb', line 6

def self.workspace
    `git config dir.workspace | envsubst`.trim
end