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 Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_repoObject (readonly)

Returns the value of attribute cache_repo.



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

def cache_repo
  @cache_repo
end

Instance Method Details

#dirty?(_exclude_spec = false) ⇒ Boolean

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

Returns:

  • (Boolean)


17
18
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
58
59
60
61
62
# File 'lib/simp/rake/build/deps.rb', line 17

def dirty?(_exclude_spec = false)
  repo_status = false

  return repo_status unless File.directory?(path)

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

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

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

    unless repo_status
      # Things that may be out of date but which should stop the updating
      # of the git repo
      our_exclusions = [
        'build/rpm_metadata',
        'dist/',
      ]

      untracked_files = `git ls-files -o -d --exclude-standard --exclude=#{our_exclusions.join(' --exclude=')}`

      raise Error, "Failure running 'git ls-files -o -d --exclude-standard' at '#{path}'" unless $CHILD_STATUS.success?

      unless untracked_files.empty?
        untracked_files.strip!

        if untracked_files.lines.any?
          repo_status = "'#{path}' has untracked files"
        end
      end

      # We should never get here

    end
  end

  repo_status
end