summaryrefslogtreecommitdiff
path: root/puppet/modules/git/manifests/changes.pp
blob: 71112051d05fcc81c7ec6a122aa922518684eaa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Usage
# git::changes { name:
#   cwd    =>  "/path/to/git/"
#   user   =>  "me",
#   ensure =>  {*assume-unchanged*, tracked}
# }
#

define git::changes ( $cwd, $user, $ensure='assume-unchanged' ) {

  case $ensure {
    default: { err ( "unknown ensure value '${ensure}'" ) }

    assume-unchanged: {
      exec { "assume-unchanged ${name}":
        command => "/usr/bin/git update-index --assume-unchanged ${name}",
        cwd     => $cwd,
        user    => $user,
        unless  => "/usr/bin/git ls-files -v | grep '^[ch] ${name}'",
      }
    }

    tracked: {
      exec { "track changes ${name}":
        command => "/usr/bin/git update-index --no-assume-unchanged ${name}",
        cwd     => $cwd,
        user    => $user,
        onlyif  => "/usr/bin/git ls-files -v | grep '^[ch] ${name}'",
      }
    }
  }
}