Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions manifests/clean.pp
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
define git::clean($localtree = '/srv/git/', $real_name = false, $user = '') {
define git::clean (
$localtree = '/srv/git/',
$real_name = false,
$user = '',
$schedule = undef) {
#
# Resource to clean out a working directory
# Useful for directories you want to pull from upstream, but might
# have added files. This resource is applied for all pull resources,
# by default.
#
if $schedule != undef {
Exec {
schedule => $schedule, }
}

#
# Resource to clean out a working directory
# Useful for directories you want to pull from upstream, but might
# have added files. This resource is applied for all pull resources,
# by default.
#
if $user == '' {
exec { "git_clean_exec_$name":
cwd => $real_name ? {
false => "$localtree/$name",
default => "$localtree/$real_name"
},
command => 'git clean -d -f'
}
if $user == '' {
exec { "git_clean_exec_$name":
cwd => $real_name ? {
false => "$localtree/$name",
default => "$localtree/$real_name"
},
command => 'git clean -d -f'
}
else {
exec { "git_clean_exec_$name":
cwd => $real_name ? {
false => "$localtree/$name",
default => "$localtree/$real_name"
},
command => "sudo -u $user git clean -d -f"
}
} else {
exec { "git_clean_exec_$name":
cwd => $real_name ? {
false => "$localtree/$name",
default => "$localtree/$real_name"
},
command => "sudo -u $user git clean -d -f"
}
}
}
29 changes: 12 additions & 17 deletions manifests/client.pp
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
class git::client {
#
# Documentation on this class
#
# This class causes the client to gain git capabilities. Boo!
#

#
# Documentation on this class
#
# This class causes the client to gain git capabilities. Boo!
#

case $::lsbdistcodename {
etch: {
os::backported_package{'git-core':
ensure => installed
}
}
case $::lsbdistcodename {
etch : {
os::backported_package { 'git-core': ensure => installed }
}

default: {
package {'git-core':
ensure => installed
}
}
default : {
package { 'git-core': ensure => installed }
}
}
}
94 changes: 51 additions & 43 deletions manifests/clone.pp
Original file line number Diff line number Diff line change
@@ -1,52 +1,60 @@
define git::clone( $source,
$localtree = '/srv/git/',
$real_name = false,
$branch = false,
$user = '') {
if $real_name {
$_name = $real_name
}
else {
$_name = $name
define git::clone (
$source,
$localtree = '/srv/git/',
$real_name = false,
$branch = false,
$user = '',
$schedule = undef) {
if $real_name {
$_name = $real_name
} else {
$_name = $name
}

if $schedule != undef {
Exec {
schedule => $schedule, }
}

if $user == '' {
exec { "git_clone_exec_$localtree/$_name":
cwd => $localtree,
command => "git clone $source $_name",
creates => "$localtree/$_name/.git/",
}

if $user == '' {
exec { "git_clone_exec_$localtree/$_name":
cwd => $localtree,
command => "git clone $source $_name",
creates => "$localtree/$_name/.git/",
case $branch {
false : {
}
default : {
exec { "git_clone_checkout_${branch}_${localtree}/${_name}":
cwd => "$localtree/$_name",
command => "git checkout --track -b $branch origin/$branch",
creates => "$localtree/$_name/.git/refs/heads/$branch"
}
}
}
} else {
exec { "git_clone_exec_$localtree/$_name":
cwd => $localtree,
command => "sudo -u $user git clone $source $_name",
creates => "$localtree/$_name/.git/",
timeout => 0
}

case $branch {
false: {}
default: {
exec { "git_clone_checkout_${branch}_${localtree}/${_name}":
cwd => "$localtree/$_name",
command => "git checkout --track -b $branch origin/$branch",
creates => "$localtree/$_name/.git/refs/heads/$branch"
}
}
case $branch {
false : {
}
} else {
exec { "git_clone_exec_$localtree/$_name":
cwd => $localtree,
command => "sudo -u $user git clone $source $_name",
creates => "$localtree/$_name/.git/",
default : {
exec { "git_clone_checkout_${branch}_${localtree}/${_name}":
cwd => "$localtree/$_name",
command => "git checkout --track -b $branch origin/$branch",
creates => "$localtree/$_name/.git/refs/heads/$branch",
user => $user,
require => User[$user],
timeout => 0
}

case $branch {
false: {}
default: {
exec { "git_clone_checkout_${branch}_${localtree}/${_name}":
cwd => "$localtree/$_name",
command => "git checkout --track -b $branch origin/$branch",
creates => "$localtree/$_name/.git/refs/heads/$branch",
user => $user,
require => User[$user],
timeout => 0
}
}
}
}
}
}
}
165 changes: 85 additions & 80 deletions manifests/pull.pp
Original file line number Diff line number Diff line change
@@ -1,95 +1,100 @@
define git::pull($localtree = '/srv/git/', $real_name = false,
$reset = true, $clean = true, $branch = false,
$git_tag = false, $user = '') {
define git::pull (
$localtree = '/srv/git/',
$real_name = false,
$reset = true,
$clean = true,
$branch = false,
$git_tag = false,
$schedule = undef,
$user = '') {
if $real_name {
$_name = $real_name
} else {
$_name = $name
}

if $real_name {
$_name = $real_name
}
else {
$_name = $name
}

#
# This resource enables one to update a working directory
# from an upstream GIT source repository. Note that by default,
# the working directory is reset (undo any changes to tracked
# files), and clean (remove untracked files)
#
# Note that to prevent a reset to be executed, you can set $reset to
# false when calling this resource.
#
# Note that to prevent a clean to be executed as part of the reset, you
# can set $clean to false
#
#
# This resource enables one to update a working directory
# from an upstream GIT source repository. Note that by default,
# the working directory is reset (undo any changes to tracked
# files), and clean (remove untracked files)
#
# Note that to prevent a reset to be executed, you can set $reset to
# false when calling this resource.
#
# Note that to prevent a clean to be executed as part of the reset, you
# can set $clean to false
#

if $reset {
git::reset { $name:
localtree => $localtree,
real_name => $real_name,
clean => $clean,
user => $user
}
if $reset {
git::reset { $name:
localtree => $localtree,
real_name => $real_name,
clean => $clean,
user => $user
}
}

if $git_tag {

if $git_tag == 'latest' {
$git_checkout_tag = '`git describe --tags $(git rev-list --tags --max-count=1)`'
} else {
$git_checkout_tag = $git_tag
}

@exec { "git_pull_exec_$name":
cwd => "$localtree/$_name",
command => "sudo -u $user git fetch --tags",
onlyif => "test -d $localtree/$_name/.git/info"
}
if $schedule != undef {
Exec {
schedule => $schedule, }
}

exec { "git_checkout_tag_${name}_${git_tag}":
cwd => "$localtree/$_name",
command => "sudo -u $user git checkout $git_checkout_tag",
creates => "$localtree/$_name/git/refs/tags/$git_checkout_tag",
}
if $git_tag {
if $git_tag == 'latest' {
$git_checkout_tag = '`git describe --tags $(git rev-list --tags --max-count=1)`'
} else {
$git_checkout_tag = $git_tag
}

if $user == '' {
@exec { "git_pull_exec_$name":
cwd => "$localtree/$_name",
command => 'git pull',
onlyif => "test -d $localtree/$_name/.git/info"
}
}
else {
@exec { "git_pull_exec_$name":
cwd => "$localtree/$_name",
command => "sudo -u $user git pull",
onlyif => "test -d $localtree/$_name/.git/info"
}
}

case $branch {
false: {}
default: {
exec { "git_pull_checkout_${branch}_${localtree}/${name}":
cwd => "$localtree/$_name",
command => "git checkout --track -b $branch origin/$branch",
creates => "$localtree/$_name/.git/refs/heads/$branch"
}
}
}
@exec { "git_pull_exec_$name":
cwd => "$localtree/$_name",
command => "sudo -u $user git fetch --tags",
onlyif => "test -d $localtree/$_name/.git/info"
}

if defined(Git::Reset[$name]) {
Exec["git_pull_exec_$name"] {
require +> Git::Reset[$name]
}
exec { "git_checkout_tag_${name}_${git_tag}":
cwd => "$localtree/$_name",
command => "sudo -u $user git checkout $git_checkout_tag",
creates => "$localtree/$_name/git/refs/tags/$git_checkout_tag",
}
} else {
if $user == '' {
@exec { "git_pull_exec_$name":
cwd => "$localtree/$_name",
command => 'git pull',
onlyif => "test -d $localtree/$_name/.git/info"
}
} else {
@exec { "git_pull_exec_$name":
cwd => "$localtree/$_name",
command => "sudo -u $user git pull",
onlyif => "test -d $localtree/$_name/.git/info"
}
}

if defined(Git::Clean[$name]) {
Exec["git_pull_exec_$name"] {
require +> Git::Clean[$name]
case $branch {
false : {
}
default : {
exec { "git_pull_checkout_${branch}_${localtree}/${name}":
cwd => "$localtree/$_name",
command => "git checkout --track -b $branch origin/$branch",
creates => "$localtree/$_name/.git/refs/heads/$branch"
}
}
}
}

if defined(Git::Reset[$name]) {
Exec["git_pull_exec_$name"] {
require +> Git::Reset[$name] }
}

if defined(Git::Clean[$name]) {
Exec["git_pull_exec_$name"] {
require +> Git::Clean[$name] }
}

realize(Exec["git_pull_exec_$name"])
realize(Exec["git_pull_exec_$name"])
}
Loading