Skip to content

Commit b7c6d0b

Browse files
committed
Merge pull request #7850 from nalimilan/gitconfig
Gitconfig
2 parents 4d305d5 + b7ed001 commit b7c6d0b

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ before_install:
2727
script:
2828
- make $BUILDOPTS prefix=/tmp/julia install
2929
- cd .. && mv julia julia2
30-
- git config --global user.name "Travis CI"
3130
- cd /tmp/julia/share/julia/test && /tmp/julia/bin/julia-debug --check-bounds=yes runtests.jl all && /tmp/julia/bin/julia-debug --check-bounds=yes runtests.jl pkg
3231
- cd - && mv julia2 julia
3332
- echo "Ready for packaging..."

base/pkg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ publish() = cd(Entry.publish,META_BRANCH)
5959
build() = cd(Entry.build)
6060
build(pkgs::String...) = cd(Entry.build,[pkgs...])
6161

62-
generate(pkg::String, license::String; force::Bool=false) =
63-
cd(Generate.package,pkg,license,force=force)
62+
generate(pkg::String, license::String; force::Bool=false, authors::Union(String,Array) = [], config::Dict={}) =
63+
cd(Generate.package,pkg,license,force=force,authors=authors,config=config)
6464

6565

6666
test(;coverage::Bool=false) = cd(Entry.test; coverage=coverage)

base/pkg/generate.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Generate
33
import ..Git, ..Read
44

55
copyright_year() = readchomp(`date +%Y`)
6-
copyright_name() = readchomp(`git config --global --get user.name`)
6+
copyright_name(dir::String) = readchomp(Git.cmd(`config --get user.name`, dir=dir))
77
github_user() = readchomp(ignorestatus(`git config --global --get github.user`))
88

99
function git_contributors(dir::String, n::Int=typemax(Int))
@@ -31,21 +31,23 @@ function package(
3131
pkg::String,
3232
license::String;
3333
force::Bool = false,
34-
authors::String = "",
34+
authors::Union(String,Array) = "",
3535
years::Union(Int,String) = copyright_year(),
3636
user::String = github_user(),
37+
config::Dict = {},
3738
)
3839
isnew = !ispath(pkg)
3940
try
4041
if isnew
4142
url = isempty(user) ? "" : "git://github.com/$user/$pkg.jl.git"
42-
Generate.init(pkg,url)
43+
Generate.init(pkg,url,config=config)
4344
else
4445
Git.dirty(dir=pkg) && error("$pkg is dirty – commit or stash your changes")
4546
end
47+
4648
Git.transact(dir=pkg) do
4749
if isempty(authors)
48-
authors = isnew ? copyright_name() : git_contributors(pkg,5)
50+
authors = isnew ? copyright_name(pkg) : git_contributors(pkg,5)
4951
end
5052
Generate.license(pkg,license,years,authors,force=force)
5153
Generate.readme(pkg,user,force=force)
@@ -81,10 +83,14 @@ function package(
8183
end
8284
end
8385

84-
function init(pkg::String, url::String="")
86+
function init(pkg::String, url::String=""; config::Dict={})
8587
if !ispath(pkg)
8688
info("Initializing $pkg repo: $(abspath(pkg))")
8789
Git.run(`init -q $pkg`)
90+
91+
for (key,val) in config
92+
Git.run(`config $key $val`, dir=pkg)
93+
end
8894
Git.run(`commit -q --allow-empty -m "initial empty commit"`, dir=pkg)
8995
end
9096
isempty(url) && return

test/git.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ mkdir(dir)
88
try cd(dir) do
99

1010
run(`git init -q`)
11+
run(`git config user.name "Julia Tester"`)
12+
run(`git config user.email [email protected]`)
1113
run(`git commit -q --allow-empty -m "initial empty commit"`)
1214
git_verify(Dict(), Dict(), Dict())
1315

test/pkg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ end
2424

2525
# testing a package with test dependencies causes them to be installed for the duration of the test
2626
temp_pkg_dir() do
27-
Pkg.generate("PackageWithTestDependencies", "MIT")
27+
Pkg.generate("PackageWithTestDependencies", "MIT", config=["user.name"=>"Julia Test", "user.email"=>"[email protected]"])
2828
@test [keys(Pkg.installed())...] == ["PackageWithTestDependencies"]
2929

3030
isdir(Pkg.dir("PackageWithTestDependencies","test")) || mkdir(Pkg.dir("PackageWithTestDependencies","test"))
@@ -47,7 +47,7 @@ end
4747

4848
# testing a package with no runtests.jl errors
4949
temp_pkg_dir() do
50-
Pkg.generate("PackageWithNoTests", "MIT")
50+
Pkg.generate("PackageWithNoTests", "MIT", config=["user.name"=>"Julia Test", "user.email"=>"[email protected]"])
5151

5252
if isfile(Pkg.dir("PackageWithNoTests", "test", "runtests.jl"))
5353
rm(Pkg.dir("PackageWithNoTests", "test", "runtests.jl"))
@@ -62,7 +62,7 @@ end
6262

6363
# testing a package with failing tests errors
6464
temp_pkg_dir() do
65-
Pkg.generate("PackageWithFailingTests", "MIT")
65+
Pkg.generate("PackageWithFailingTests", "MIT", config=["user.name"=>"Julia Test", "user.email"=>"[email protected]"])
6666

6767
isdir(Pkg.dir("PackageWithFailingTests","test")) || mkdir(Pkg.dir("PackageWithFailingTests","test"))
6868
open(Pkg.dir("PackageWithFailingTests", "test", "runtests.jl"),"w") do f

0 commit comments

Comments
 (0)