Skip to content

Commit 8181be7

Browse files
committed
Add git::subtree class to install git-subtree
1 parent 0347d63 commit 8181be7

File tree

5 files changed

+75
-1
lines changed

5 files changed

+75
-1
lines changed

Modulefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ license 'Apache 2.0'
66
summary 'module for installing git'
77
description 'module for installing git'
88
project_page 'https://github.com/puppetlabs/puppetlabs-git/'
9-
9+
dependency 'puppetlabs/vcsrepo'
1010

files/subtree/bash_completion.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!bash
2+
#
3+
# bash completion support for Git subtree.
4+
#
5+
# To use this routine:
6+
#
7+
# 1) Make sure you have installed and configured the core Git completion script, which is required to make this script work;
8+
# 2) Copy this file to somewhere (e.g. ~/.git-subtree-completion.sh);
9+
# 3) Added the following line to your .bashrc:
10+
# source ~/.git-subtree-completion.sh
11+
#
12+
13+
_git_subtree ()
14+
{
15+
local cur="${COMP_WORDS[COMP_CWORD]}"
16+
17+
if [ $COMP_CWORD -eq 2 ]; then
18+
__gitcomp "add merge pull push split"
19+
return
20+
elif [ $COMP_CWORD -eq 3 ]; then
21+
__gitcomp "--prefix="
22+
return
23+
fi
24+
__gitcomp "$(__git_remotes)"
25+
}

lib/facter/git_exec_path.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# git_exec_path.rb
2+
Facter.add('git_exec_path') do
3+
setcode 'git --exec-path 2>/dev/null'
4+
end

lib/facter/git_version.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# git_version
2+
Facter.add('git_version') do
3+
setcode 'git --version 2>/dev/null'
4+
end

manifests/subtree.pp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# == Class: git::subtree
2+
#
3+
# Installs and configure git-subtree
4+
#
5+
class git::subtree {
6+
7+
Package['git'] -> Class['git::subtree']
8+
9+
if (versioncmp('1.7.0', $::git_version) >= 0) {
10+
fail 'git-subtree requires git 1.7 or later!'
11+
}
12+
13+
if (versioncmp('1.7.11', $::git_version) >= 0) {
14+
$source_dir = '/usr/src/git-subtree'
15+
vcsrepo { $source_dir:
16+
ensure => present,
17+
source => 'http://github.com/apenwarr/git-subtree.git',
18+
provider => 'git',
19+
revision => '2793ee6ba',
20+
}
21+
} else {
22+
$source_dir = '/usr/share/doc/git-core/contrib/subtree'
23+
}
24+
25+
exec { "/usr/bin/make prefix=/usr libexecdir=${::git_exec_path}":
26+
creates => "${source_dir}/git-subtree",
27+
cwd => $source_dir,
28+
}
29+
->
30+
exec { "/usr/bin/make prefix=/usr libexecdir=${::git_exec_path} install":
31+
creates => "${::git_exec_path}/git-subtree",
32+
cwd => $source_dir,
33+
}
34+
35+
file { '/etc/bash_completion.d/git-subtree':
36+
ensure => file,
37+
source => 'puppet:///modules/git/subtree/bash_completion.sh',
38+
mode => '0644',
39+
}
40+
41+
}

0 commit comments

Comments
 (0)