Skip to content

Commit

Permalink
check for valid git version number in pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebolewski committed Nov 21, 2014
1 parent 489ca64 commit 9eca53d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Building Julia requires that the following software be installed:
- **[GNU make]** — building dependencies.
- **[gcc & g++][gcc]** (>= 4.4) or **[Clang][clang]** (>= 3.1, Xcode 4.3.3 on OS X) — compiling and linking C, C++
- **[gfortran][gcc]** — compiling and linking fortran libraries
- **[git]** — version control and package management.
- **[git]** — version control and package management (version 1.7.3+ required)
- **[perl]** — preprocessing of header files of libraries.
- **[wget]**, **[curl]**, or **[fetch]** (FreeBSD) — to automatically download external libraries.
- **[m4]** — needed to build GMP.
Expand Down
3 changes: 3 additions & 0 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function cd(f::Function, args...; kws...)
end

function init(meta::AbstractString=DEFAULT_META, branch::AbstractString=META_BRANCH)
if Git.version() < v"1.7.3"
warn("Pkg only works with git versions greater than v1.7.3")
end
dir = path()
info("Initializing package repository $dir")
if isdir(joinpath(dir,"METADATA"))
Expand Down
10 changes: 10 additions & 0 deletions base/pkg/git.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ function success(args::Cmd; dir="")
Base.success(`$g $args`)
end

function version()
vs = split(readchomp(`version`), ' ')[3]
ns = split(vs, '.')
if length(ns) > 3
VersionNumber(join(ns[1:3], '.'))
else
VersionNumber(join(ns, '.'))
end
end

modules(args::Cmd; dir="") = readchomp(`config -f .gitmodules $args`, dir=dir)
different(verA::AbstractString, verB::AbstractString, path::AbstractString; dir="") =
!success(`diff-tree --quiet $verA $verB -- $path`, dir=dir)
Expand Down
4 changes: 3 additions & 1 deletion test/git.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Base.Git
include("gitutils.jl")

@test Git.version() >= v"1.7.3"

dir = string("tmp.",randstring())
@test !ispath(dir)
mkdir(dir)
Expand All @@ -19,7 +21,7 @@ try cd(dir) do
# for a total of 64^2 = 4096 files needed to test all transitions
# between before and after superpositions of git repo states.

contents = [nothing, "foo", "bar", {"baz"=>"qux"}]
contents = [nothing, "foo", "bar", Dict{Any,Any}("baz"=>"qux")]
b = length(contents)
states = [ [ base(b,k,6) => contents[rem(div(k,b^p),b)+1] for k=0:(b^3)^2-1 ] for p=0:5 ]

Expand Down

0 comments on commit 9eca53d

Please sign in to comment.