Update show style

This commit is contained in:
Chris de Graaf 2017-12-07 16:43:40 +00:00
parent ffd288a6b2
commit 7e38c92413
4 changed files with 30 additions and 33 deletions

View File

@ -70,6 +70,7 @@ config template file doesn't follow the generic naming convention, we added anot
abstract type GenericPlugin <: Plugin end
function show(io::IO, p::GenericPlugin)
spc = " "
t = split(string(typeof(p)), ".")[end]
println(io, "$t:")
@ -78,11 +79,11 @@ function show(io::IO, p::GenericPlugin)
else
dirname(get(p.src)) == DEFAULTS_DIR ? "Default" : get(p.src)
end
println(io, " Config file: $cfg")
println(io, "$spc→ Config file: $cfg")
n = length(p.gitignore)
s = n == 1 ? "" : "s"
print(io, " $n gitignore entrie$s")
print(io, "$spc→ $n gitignore entrie$s")
n > 0 && print(io, ": $(join(map(g -> "\"$g\"", p.gitignore), ", "))")
end

View File

@ -120,28 +120,26 @@ function show(io::IO, t::Template)
println(io, "Template:")
println(io, "$spc→ User: $(maybe_none(t.user))")
println(io, "$spc→ Host: $(maybe_none(t.host))")
println(io, "$spc→ License: $(maybe_none(t.license))")
# We don't care about authors or license years if there is no license.
if !isempty(t.license)
# TODO: Authors could be split into multiple lines if there are more than one.
# Maybe the authors field of Template should be an array (or Dict, see #4).
println(io, "$spc→ Authors: $(maybe_none(t.authors))")
println(io, "$spc→ License years: $(maybe_none(t.years))")
print(io, "$spc→ License: ")
if isempty(t.license)
println(io, "None")
else
println(io, "$(t.license) ($(t.authors) $(t.years))")
end
println(io, "$spc→ Package directory: $(replace(maybe_none(t.dir), homedir(), "~"))")
println(io, "$spc→ Precompilation enabled: $(t.precompile ? "yes" : "no")")
println(io, "$spc→ Precompilation enabled: $(t.precompile ? "Yes" : "No")")
println(io, "$spc→ Minimum Julia version: v$(t.julia_version)")
print(io, "$spc→ Package dependencies:")
n = length(t.requirements)
s = n == 1 ? "" : "s"
print(io, "$spc→ $n package requirement$s")
if isempty(t.requirements)
println(io, " None")
else
println(io)
for req in sort(t.requirements)
println(io, "$(spc^2)$req")
end
else
println(io, ": $(join(t.requirements, ", "))")
end
print(io, "$spc→ Git configuration options:")

View File

@ -135,13 +135,11 @@ end
Template:
User: $me
Host: github.com
License: MIT
Authors: $(gitconfig["user.name"])
License years: 2017
License: MIT ($(gitconfig["user.name"]) $(Dates.year(now())))
Package directory: $pkgdir
Precompilation enabled: yes
Precompilation enabled: Yes
Minimum Julia version: v$VERSION
Package dependencies: None
0 package requirements
Git configuration options:
github.user = $(gitconfig["github.user"])
user.email = $(gitconfig["user.email"])
@ -168,11 +166,9 @@ end
Host: github.com
License: None
Package directory: $pkgdir
Precompilation enabled: yes
Precompilation enabled: Yes
Minimum Julia version: v$VERSION
Package dependencies:
Bar
Foo
2 package requirements: Bar, Foo
Git configuration options:
github.user = $(gitconfig["github.user"])
user.email = $(gitconfig["user.email"])
@ -294,6 +290,8 @@ end
remote = LibGit2.get(LibGit2.GitRemote, repo, "origin")
branches = [LibGit2.shortname(branch[1]) for branch in LibGit2.GitBranchIter(repo)]
@test LibGit2.getconfig(repo, "user.name", "") == gitconfig["user.name"]
# Note: This test will fail on your system if you've configured Git
# to replace all HTTPS URLs with SSH.
@test LibGit2.url(remote) == "https://github.com/$me/$test_pkg.jl"
@test in("master", branches)
@test !in("gh-pages", branches)