Class: R10K::Git::ShellGit::ThinRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/simp/rake/build/deps.rb

Overview

Horrible, but we need to be able to manipulate the cache

Instance Method Summary collapse

Instance Method Details

#cache_repoObject



14
15
16
# File 'lib/simp/rake/build/deps.rb', line 14

def cache_repo
  @cache_repo
end

#dirty?Boolean

Return true if the repository has local modifications, false otherwise.

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/simp/rake/build/deps.rb', line 19

def dirty?
  repo_status = false

  return repo_status unless File.directory?(path)

  Dir.chdir(path) do
    %x(git update-index -q --ignore-submodules --refresh)
    repo_status = "Could not update git index for '#{path}'" unless $?.success?

    unless repo_status
      %x(git diff-files --quiet --ignore-submodules --)
      repo_status = "'#{path}' has unstaged changes" unless $?.success?
    end

    unless repo_status
      %x(git diff-index --cached --quiet HEAD --ignore-submodules --)
      repo_status = "'#{path}' has uncommitted changes" unless $?.success?
    end

    unless repo_status
      untracked_files = %x(git ls-files -o -d --exclude-standard)

      if $?.success?
        unless untracked_files.empty?
          untracked_files.strip!

          if untracked_files.lines.count > 0
            repo_status = "'#{path}' has untracked files"
          end
        end
      else
        # We should never get here
        raise Error, "Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'"
      end
    end
  end

  repo_status
end