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 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 63 64 65 66 67 68 69 70 71
|
###
# A file distribution based on git
###
::clay::define ::practcl::distribution.git {
superclass ::practcl::distribution
method ScmTag {} {
if {[my define exists scm_tag]} {
return [my define get scm_tag]
}
if {[my define exists tag]} {
set tag [my define get tag]
} else {
set tag master
}
my define set scm_tag $tag
return $tag
}
method ScmUnpack {} {
set srcdir [my SrcDir]
if {[file exists [file join $srcdir .git]]} {
return 0
}
set CWD [pwd]
set tag [my ScmTag]
set pkg [my define get name]
if {[my define exists git_url]} {
::practcl::doexec git clone --branch $tag [my define get git_url] $srcdir
} else {
::practcl::doexec git clone --branch $tag https://github.com/eviltwinskippy/$pkg $srcdir
}
return 1
}
method ScmUpdate {} {
if {[my ScmUnpack]} {
return
}
set CWD [pwd]
set srcdir [my SrcDir]
set tag [my ScmTag]
::practcl::doexec_in $srcdir git pull
cd $CWD
}
}
oo::objdefine ::practcl::distribution.git {
method claim_object obj {
set path [$obj define get srcdir]
if {[my claim_path $path]} {
return true
}
if {[$obj define get git_url] ne {}} {
return true
}
return false
}
method claim_option {} {
return git
}
method claim_path path {
if {[file exists [file join $path .git]]} {
return true
}
return false
}
}
|