Update logging and examples

This commit is contained in:
Chris de Graaf 2017-10-27 15:31:34 +01:00
parent 0956dc87fb
commit 4974e58af9
3 changed files with 23 additions and 23 deletions

View File

@ -23,20 +23,20 @@ The simplest template only requires your GitHub username.
```julia ```julia
julia> using PkgTemplates julia> using PkgTemplates
julia> t = Template(; user="myusername") julia> t = Template(; user="myusername");
julia> generate("MyPkg", t) julia> generate("MyPkg", t)
INFO: Initialized git repo at /tmp/tmpvaHVki/MyPkg INFO: Initialized git repo at /tmp/tmpvaHVki/MyPkg
INFO: Made initial empty commit INFO: Made empty initial commit
INFO: Set remote origin to https://github.com/myusername/MyPkg.jl INFO: Set remote origin to https://github.com/myusername/MyPkg.jl
INFO: Staged 5 files/directories: src/, test/, REQUIRE, .gitignore, README.md INFO: Staged 6 files/directories: src/, test/, REQUIRE, README.md, .gitignore, LICENSE
INFO: Committed files generated by PkgTemplates INFO: Committed files generated by PkgTemplates
INFO: Moving temporary package directory into /home/degraafc/.julia/v0.6/ INFO: Moved temporary package directory into /home/degraafc/.julia/v0.6/
INFO: Finished INFO: Finished
julia> cd(joinpath(t.dir, "MyPkg")); run(`git ls-tree -r --name-only HEAD`) julia> run(`git -C $(joinpath(t.dir, "MyPkg")) ls-tree -r --name-only HEAD`)
.gitignore .gitignore
.travis.yml LICENSE
README.md README.md
REQUIRE REQUIRE
src/MyPkg.jl src/MyPkg.jl
@ -48,7 +48,7 @@ However, we can also configure a number of keyword arguments to `Template` and
```julia ```julia
julia> t = Template(; julia> t = Template(;
user="myusername", user="myusername",
license="MIT", license="ISC",
authors=["Chris de Graaf", "Invenia Technical Computing Corporation"], authors=["Chris de Graaf", "Invenia Technical Computing Corporation"],
years="2016-2017", years="2016-2017",
dir=joinpath(homedir(), "code"), dir=joinpath(homedir(), "code"),
@ -57,26 +57,26 @@ julia> t = Template(;
gitconfig=Dict("diff.renames" => true), gitconfig=Dict("diff.renames" => true),
plugins=[ plugins=[
TravisCI(), TravisCI(),
CodeCov(; config_file=nothing), CodeCov(),
Coveralls(), Coveralls(),
AppVeyor(), AppVeyor(),
GitHubPages(), GitHubPages(),
], ],
) );
julia> generate("MyPkg", t; force=true, ssh=true) julia> generate("MyPkg", t; force=true, ssh=true)
INFO: Initialized git repo at /tmp/tmpe0dWY5/MyPkg INFO: Initialized git repo at /tmp/tmpe0dWY5/MyPkg
INFO: Applying git configuration INFO: Applied git configuration
INFO: Made initial empty commit INFO: Made empty initial commit
INFO: Set remote origin to git@github.com:myusername/MyPkg.jl.git INFO: Set remote origin to git@github.com:myusername/MyPkg.jl.git
INFO: Created empty gh-pages branch INFO: Created empty gh-pages branch
INFO: Staged 9 files/directories: src/, test/, REQUIRE, README.md, .gitignore, LICENSE, .travis.yml, .appveyor.yml, docs/ INFO: Staged 9 files/directories: src/, test/, REQUIRE, README.md, .gitignore, LICENSE, docs/, .appveyor.yml, .travis.yml
INFO: Committed files generated by PkgTemplates INFO: Committed files generated by PkgTemplates
INFO: Moving temporary package directory into /home/degraafc/code/ INFO: Moved temporary package directory into /home/degraafc/code/
INFO: Finished INFO: Finished
WARNING: Remember to push all created branches to your remote: git push --all WARNING: Remember to push all created branches to your remote: git push --all
julia> cd(joinpath(t.dir, "MyPkg")); run(`git ls-tree -r --name-only HEAD`) julia> run(`git -C $(joinpath(t.dir, "MyPkg")) ls-tree -r --name-only HEAD`)
.appveyor.yml .appveyor.yml
.gitignore .gitignore
.travis.yml .travis.yml

View File

@ -22,9 +22,9 @@ The simplest template only requires your GitHub username.
```@repl ```@repl
using PkgTemplates using PkgTemplates
t = Template(; user="myusername") t = Template(; user="myusername");
generate("MyPkg", t) generate("MyPkg", t)
cd(joinpath(t.dir, "MyPkg")); run(`git ls-tree -r --name-only HEAD`) run(`git -C $(joinpath(t.dir, "MyPkg")) ls-tree -r --name-only HEAD`)
``` ```
However, we can also configure a number of keyword arguments to However, we can also configure a number of keyword arguments to
@ -43,14 +43,14 @@ t = Template(;
gitconfig=Dict("diff.renames" => true), gitconfig=Dict("diff.renames" => true),
plugins=[ plugins=[
TravisCI(), TravisCI(),
CodeCov(; config_file=nothing), CodeCov(),
Coveralls(), Coveralls(),
AppVeyor(), AppVeyor(),
GitHubPages(), GitHubPages(),
], ],
) );
generate("MyPkg", t; force=true, ssh=true) generate("MyPkg", t; force=true, ssh=true)
cd(joinpath(t.dir, "MyPkg")); run(`git ls-tree -r --name-only HEAD`) run(`git -C $(joinpath(t.dir, "MyPkg")) ls-tree -r --name-only HEAD`)
``` ```
If that looks like a lot of work, you can also create templates interactively If that looks like a lot of work, you can also create templates interactively

View File

@ -53,14 +53,14 @@ function generate(
# Initialize the repo and configure it. # Initialize the repo and configure it.
repo = LibGit2.init(temp_pkg_dir) repo = LibGit2.init(temp_pkg_dir)
info("Initialized git repo at $temp_pkg_dir") info("Initialized git repo at $temp_pkg_dir")
!isempty(t.gitconfig) && info("Applying git configuration")
LibGit2.with(LibGit2.GitConfig, repo) do cfg LibGit2.with(LibGit2.GitConfig, repo) do cfg
for (key, val) in t.gitconfig for (key, val) in t.gitconfig
LibGit2.set!(cfg, key, val) LibGit2.set!(cfg, key, val)
end end
end end
LibGit2.commit(repo, "Empty initial commit") !isempty(t.gitconfig) && info("Applied git configuration")
info("Made initial empty commit") LibGit2.commit(repo, "Initial commit")
info("Made empty initial commit")
rmt = if ssh rmt = if ssh
"git@$(t.host):$(t.user)/$pkg_name.jl.git" "git@$(t.host):$(t.user)/$pkg_name.jl.git"
else else
@ -94,10 +94,10 @@ function generate(
LibGit2.commit(repo, "Files generated by PkgTemplates") LibGit2.commit(repo, "Files generated by PkgTemplates")
info("Committed files generated by PkgTemplates") info("Committed files generated by PkgTemplates")
multiple_branches = length(collect(LibGit2.GitBranchIter(repo))) > 1 multiple_branches = length(collect(LibGit2.GitBranchIter(repo))) > 1
info("Moving temporary package directory into $(t.dir)/")
try try
mkpath(dirname(pkg_dir)) mkpath(dirname(pkg_dir))
mv(temp_pkg_dir, pkg_dir; remove_destination=force) mv(temp_pkg_dir, pkg_dir; remove_destination=force)
info("Moved temporary package directory into $(t.dir)/")
catch # Likely cause is that t.dir can't be created (is a file, etc.). catch # Likely cause is that t.dir can't be created (is a file, etc.).
# We're just going to trust that backup_dir is a valid directory. # We're just going to trust that backup_dir is a valid directory.
backup_dir = if isempty(backup_dir) backup_dir = if isempty(backup_dir)