Skip to content

Commit 3dec910

Browse files
authored
Merge pull request #21 from crstnbr/v1.0
Julia 1.0 support
2 parents 1473a64 + 38f0b72 commit 3dec910

File tree

7 files changed

+93
-99
lines changed

7 files changed

+93
-99
lines changed

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
89
- nightly
910
notifications:
1011
email: false
12+
matrix:
13+
allow_failures:
14+
- julia: nightly
1115
# uncomment the following lines to override the default test script
1216
#script:
1317
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi

REQUIRE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
julia 0.6
2-
Compat 0.8.4
1+
julia 0.7
32
BinDeps
3+
VersionParsing
44
@osx Homebrew

appveyor.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
5-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
6-
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
- x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
matrix:
12+
allow_failures:
13+
- julia_version: nightly
714

815
branches:
916
only:
1017
- master
1118
- /release-.*/
1219

13-
skip_commits:
14-
message: /\[av skip\]/
15-
1620
notifications:
1721
- provider: Email
1822
on_build_success: false
1923
on_build_failure: false
2024
on_build_status_changed: false
2125

2226
install:
23-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
24-
# If there's a newer build queued for the same PR, cancel this one
25-
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
26-
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
27-
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
28-
throw "There are newer queued builds for this pull request, failing early." }
29-
# Download most recent Julia Windows binary
30-
- ps: (new-object net.webclient).DownloadFile(
31-
$env:JULIA_URL,
32-
"C:\projects\julia-binary.exe")
33-
# Run installer silently, output to C:\projects\julia
34-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
27+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
3528

3629
build_script:
37-
# Need to convert from shallow to complete for Pkg.clone to work
38-
- IF EXIST .git\shallow (git fetch --unshallow)
39-
- C:\projects\julia\bin\julia -e "versioninfo();
40-
Pkg.clone(pwd(), \"Git\"); Pkg.build(\"Git\")"
30+
- echo "%JL_BUILD_SCRIPT%"
31+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
4132

4233
test_script:
43-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"Git\")"
34+
- echo "%JL_TEST_SCRIPT%"
35+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
36+
37+
# Uncomment to support code coverage upload. Should only be enabled for packages
38+
# which would have coverage gaps without running on Windows
39+
on_success:
40+
- echo "%JL_CODECOV_SCRIPT%"
41+
- C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

deps/build.jl

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
using Compat
2-
import BinDeps: download_cmd, unpack_cmd, splittarpath
3-
if is_apple()
1+
using Base.Sys: isapple, islinux, iswindows
2+
using BinDeps
3+
using BinDeps: download_cmd, unpack_cmd, splittarpath
4+
5+
if isapple()
46
using Homebrew
57
end
68

79
function download_and_unpack(baseurl, filename)
810
downloadurl = baseurl * filename
9-
info("Downloading $filename from $downloadurl\nTo avoid this " *
10-
"download, install git manually and add it to your path " *
11-
"before\nrunning Pkg.add(\"Git\") or Pkg.build(\"Git\")")
11+
@info "Downloading $filename from $downloadurl\nTo avoid this " *
12+
"download, install git manually and add it to your path " *
13+
"before\nrunning Pkg.add(\"Git\") or Pkg.build(\"Git\")"
1214
dest = joinpath("usr", string(Sys.MACHINE))
1315
for dir in ("downloads", "usr", dest)
1416
isdir(dir) || mkdir(dir)
@@ -17,23 +19,24 @@ function download_and_unpack(baseurl, filename)
1719
isfile(filename) || run(download_cmd(downloadurl, filename))
1820
# TODO: checksum validation
1921
(b, ext, sec_ext) = splittarpath(filename)
20-
run(unpack_cmd(filename, dest, is_windows() ? ".7z" : ext, sec_ext))
22+
run(unpack_cmd(filename, dest, iswindows() ? ".7z" : ext, sec_ext))
2123
# TODO: make this less noisy on windows, see how WinRPM does it
2224
end
2325

2426
gitcmd = `git`
2527
gitver = "notfound"
2628
try
27-
gitver = readchomp(`$gitcmd --version`)
29+
global gitver = readchomp(`$gitcmd --version`)
30+
catch
2831
end
2932
if gitver == "notfound"
30-
if is_apple()
33+
if isapple()
3134
# we could allow other options, but lots of other packages already
3235
# depend on Homebrew.jl on mac and it needs a working git to function
3336
error("Working git not found on path, try running\nPkg.build(\"Homebrew\")")
3437
end
3538
baseurl = ""
36-
if is_linux() && (Sys.ARCH in (:x86_64, :i686, :i586, :i486, :i386))
39+
if islinux() && (Sys.ARCH in (:x86_64, :i686, :i586, :i486, :i386))
3740
# use conda for a non-root option on x86/amd64 linux
3841
# TODO? use conda-forge when we no longer build julia on centos 5
3942
gitver = "2.6.4"
@@ -47,7 +50,7 @@ if gitver == "notfound"
4750
zlibver = "1.2.8"
4851
zlibbase = "http://anaconda.org/anaconda/zlib/$zlibver/$plat"
4952
download_and_unpack(zlibbase, "zlib-$zlibver-3.tar.bz2")
50-
elseif is_windows()
53+
elseif iswindows()
5154
# download and extract portablegit
5255
gitver = "2.9.0"
5356
baseurl = "https://github.com/git-for-windows/git/releases/download/"
@@ -59,24 +62,27 @@ if gitver == "notfound"
5962
gitcmd = `$gitpath`
6063
end
6164
try
62-
gitver = readchomp(`$gitcmd --version`)
63-
info("Successfully installed $gitver to $gitcmd")
65+
global gitver = readchomp(`$gitcmd --version`)
66+
@info "Successfully installed $gitver to $gitcmd"
6467
# TODO: fix a warning about missing /templates here on linux
6568
# by setting an environment variable in deps.jl
6669
catch err
67-
error("Could not automatically install git, error was: $err\n" *
68-
(is_windows() ? "Report an issue at https://github.com/JuliaPackaging/Git.jl/issues/new" :
69-
"Try installing git via your system package manager then running\nPkg.build(\"Git\")"))
70+
s = if iswindows()
71+
"Report an issue at https://github.com/JuliaPackaging/Git.jl/issues/new"
72+
else
73+
"Try installing git via your system package manager then running\nPkg.build(\"Git\")"
74+
end
75+
error("Could not automatically install git, error was: $err\n" * s)
7076
end
7177
else
7278
try
7379
# this is in a try because some environments like centos 7
7480
# docker containers don't have `which` installed by default
75-
gitpath = chomp(readlines(is_windows() ? `where git` : `which git`)[1])
76-
gitcmd = `$gitpath`
81+
global gitpath = chomp(readlines(iswindows() ? `where git` : `which git`)[1])
82+
global gitcmd = `$gitpath`
83+
catch
7784
end
78-
info("Using $gitver found on path" * (gitcmd == `git` ?
79-
"" : " at $gitcmd"))
85+
@info "Using $gitver found on path" * (gitcmd == `git` ? "" : " at $gitcmd")
8086
end
8187
open("deps.jl", "w") do f
8288
println(f, "gitcmd = $gitcmd")

src/Git.jl

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module Git
44
#
55
# some utility functions for working with git repos
66
#
7-
using Compat
8-
import Base: shell_escape
7+
using Base: shell_escape
8+
using VersionParsing
99
export gitcmd # determined by deps/build.jl and saved in deps/deps.jl
1010

1111
depsjl = joinpath(dirname(@__FILE__), "..", "deps", "deps.jl")
@@ -47,20 +47,20 @@ Return a Git command from the given arguments, acting on the repository given in
4747
cmd(args::Cmd; dir="") = `$(git(dir)) $args`
4848

4949
"""
50-
Git.run(args; dir="", out=STDOUT)
50+
Git.run(args; dir="", out=stdout)
5151
5252
Execute the Git command from the given arguments `args` on the repository `dir`, writing
5353
the results to the output stream `out`.
5454
"""
55-
run(args::Cmd; dir="", out=STDOUT) = Base.run(pipeline(cmd(args,dir=dir), out))
55+
run(args::Cmd; dir="", out=stdout) = Base.run(pipeline(cmd(args,dir=dir), out))
5656

5757
"""
5858
Git.readstring(args; dir="")
5959
6060
Read the result of the Git command using the given arguments on the given repository
6161
as a string.
6262
"""
63-
readstring(args::Cmd; dir="") = Base.readstring(cmd(args,dir=dir))
63+
readstring(args::Cmd; dir="") = read(cmd(args,dir=dir), String)
6464

6565
"""
6666
Git.readchomp(args; dir="")
@@ -88,15 +88,7 @@ end
8888
8989
Return the version of Git being used by the package.
9090
"""
91-
function version()
92-
vs = split(readchomp(`version`), ' ')[3]
93-
ns = split(vs, '.')
94-
if length(ns) > 3
95-
VersionNumber(join(ns[1:3], '.'))
96-
else
97-
VersionNumber(join(ns, '.'))
98-
end
99-
end
91+
version() = vparse(readchomp(`version`))
10092

10193
"""
10294
Git.modules(args; dir="")
@@ -147,7 +139,7 @@ single SHA1 or a vector of SHA1s.
147139
"""
148140
iscommit(name; dir="") = success(`cat-file commit $name`, dir=dir)
149141
function iscommit(sha1s::Vector; dir="")
150-
indexin(sha1s,split(readchomp(`log --all --format=%H`, dir=dir),"\n")).!=0
142+
indexin(sha1s,split(readchomp(`log --all --format=%H`, dir=dir),"\n")).!=nothing
151143
end
152144

153145
"""
@@ -172,7 +164,7 @@ Return the commit to which HEAD currently refers.
172164
head(; dir="") = readchomp(`rev-parse HEAD`, dir=dir)
173165

174166

175-
immutable State
167+
struct State
176168
head::String
177169
index::String
178170
work::String

test/gitutils.jl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# This file was a part of Julia. License is MIT: http://julialang.org/license
22

3-
import Compat: readstring
4-
53
function write_and_readchomp(data, cmd::Cmd)
6-
r, w, p = readandwrite(cmd)
7-
print(w,data); close(w)
8-
v = readchomp(r)
4+
p = open(cmd, "r+")
5+
print(p.in, data)
6+
close(p.in)
7+
v = readchomp(p.out)
98
wait(p)
109
return v
1110
end
@@ -39,7 +38,7 @@ function verify_tree(d::Dict, tree::AbstractString)
3938
data = d[name]
4039
if isa(data, AbstractString)
4140
@test kind == "blob"
42-
@test data == readstring(`$gitcmd cat-file blob $sha1`)
41+
@test data == read(`$gitcmd cat-file blob $sha1`, String)
4342
elseif isa(data, Dict)
4443
@test kind == "tree"
4544
verify_tree(data, sha1)
@@ -64,7 +63,7 @@ function verify_work(d::Dict)
6463
@test ispath(name)
6564
if isa(data, AbstractString)
6665
@test isfile(name)
67-
@test readstring(name) == data
66+
@test read(name, String) == data
6867
elseif isa(data, Dict)
6968
cd(name) do
7069
verify_work(data)

test/runtests.jl

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,37 @@
11
# This file was a part of Julia. License is MIT: http://julialang.org/license
22

33
using Git
4-
using Base.Test
4+
using Test
55

66
include("gitutils.jl")
77

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

10-
dir = string("tmp.",randstring())
11-
@test !ispath(dir)
12-
mkdir(dir)
13-
@test isdir(dir)
14-
try cd(dir) do
15-
run(`$gitcmd init -q`)
16-
run(`$gitcmd config user.name "Julia Tester"`)
17-
run(`$gitcmd config user.email [email protected]`)
18-
run(`$gitcmd commit -q --allow-empty -m "initial empty commit"`)
19-
git_verify(Dict(), Dict(), Dict())
10+
mktempdir() do dir
11+
cd(dir) do
12+
run(`$gitcmd init -q`)
13+
run(`$gitcmd config user.name "Julia Tester"`)
14+
run(`$gitcmd config user.email [email protected]`)
15+
run(`$gitcmd commit -q --allow-empty -m "initial empty commit"`)
16+
git_verify(Dict(), Dict(), Dict())
2017

21-
# each path can have one of these content in each of head, index, work
22-
# for a total of length(contents)^3 = 4^3 = 64 combinations.
23-
# each path can be in any of these 64 "superpositions" before & after
24-
# for a total of 64^2 = 4096 files needed to test all transitions
25-
# between before and after superpositions of git repo states.
18+
# each path can have one of these content in each of head, index, work
19+
# for a total of length(contents)^3 = 4^3 = 64 combinations.
20+
# each path can be in any of these 64 "superpositions" before & after
21+
# for a total of 64^2 = 4096 files needed to test all transitions
22+
# between before and after superpositions of git repo states.
2623

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

31-
git_setup(states[1:3]...)
32-
try Git.transact() do
33-
git_setup(states[4:6]...)
34-
throw(nothing)
35-
end catch x
36-
x === nothing || rethrow()
28+
git_setup(states[1:3]...)
29+
try Git.transact() do
30+
git_setup(states[4:6]...)
31+
throw(nothing)
32+
end catch x
33+
x === nothing || rethrow()
34+
end
35+
git_verify(states[1:3]...)
3736
end
38-
git_verify(states[1:3]...)
39-
end
40-
finally
41-
rm(dir, recursive=true)
4237
end

0 commit comments

Comments
 (0)