Merge pull request #39 from invenia/cdg/manifest
Don't commit manifest by default
This commit is contained in:
commit
2822ae4619
@ -145,7 +145,7 @@ function gen_tests(pkg_dir::AbstractString, t::Template)
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, "test", "runtests.jl"), text)
|
gen_file(joinpath(pkg_dir, "test", "runtests.jl"), text)
|
||||||
return ["Manifest.toml", "test/"]
|
return ["test/"]
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -217,6 +217,7 @@ Returns an array of generated file/directory names.
|
|||||||
function gen_gitignore(pkg_dir::AbstractString, t::Template)
|
function gen_gitignore(pkg_dir::AbstractString, t::Template)
|
||||||
pkg = basename(pkg_dir)
|
pkg = basename(pkg_dir)
|
||||||
seen = [".DS_Store"]
|
seen = [".DS_Store"]
|
||||||
|
t.manifest || push!(seen, "Manifest.toml")
|
||||||
patterns = vcat(map(p -> p.gitignore, values(t.plugins))...)
|
patterns = vcat(map(p -> p.gitignore, values(t.plugins))...)
|
||||||
for pattern in patterns
|
for pattern in patterns
|
||||||
if !in(pattern, seen)
|
if !in(pattern, seen)
|
||||||
@ -226,7 +227,9 @@ function gen_gitignore(pkg_dir::AbstractString, t::Template)
|
|||||||
text = join(seen, "\n")
|
text = join(seen, "\n")
|
||||||
|
|
||||||
gen_file(joinpath(pkg_dir, ".gitignore"), text)
|
gen_file(joinpath(pkg_dir, ".gitignore"), text)
|
||||||
return [".gitignore"]
|
files = [".gitignore"]
|
||||||
|
t.manifest && push!(files, "Manifest.toml")
|
||||||
|
return files
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -23,6 +23,7 @@ create a template, you can use [`interactive_template`](@ref) instead.
|
|||||||
package will go. Relative paths are converted to absolute ones at template creation time.
|
package will go. Relative paths are converted to absolute ones at template creation time.
|
||||||
* `julia_version::VersionNumber=$VERSION`: Minimum allowed Julia version.
|
* `julia_version::VersionNumber=$VERSION`: Minimum allowed Julia version.
|
||||||
* `ssh::Bool=false`: Whether or not to use SSH for the remote.
|
* `ssh::Bool=false`: Whether or not to use SSH for the remote.
|
||||||
|
* `manifest::Bool=false`: Whether or not to commit the `Manifest.toml`.
|
||||||
* `plugins::Vector{<:Plugin}=Plugin[]`: A list of `Plugin`s that the package will include.
|
* `plugins::Vector{<:Plugin}=Plugin[]`: A list of `Plugin`s that the package will include.
|
||||||
"""
|
"""
|
||||||
@auto_hash_equals struct Template
|
@auto_hash_equals struct Template
|
||||||
@ -33,6 +34,7 @@ create a template, you can use [`interactive_template`](@ref) instead.
|
|||||||
dir::AbstractString
|
dir::AbstractString
|
||||||
julia_version::VersionNumber
|
julia_version::VersionNumber
|
||||||
ssh::Bool
|
ssh::Bool
|
||||||
|
manifest::Bool
|
||||||
plugins::Dict{DataType, Plugin}
|
plugins::Dict{DataType, Plugin}
|
||||||
|
|
||||||
function Template(;
|
function Template(;
|
||||||
@ -43,6 +45,7 @@ create a template, you can use [`interactive_template`](@ref) instead.
|
|||||||
dir::AbstractString=Pkg.devdir(),
|
dir::AbstractString=Pkg.devdir(),
|
||||||
julia_version::VersionNumber=VERSION,
|
julia_version::VersionNumber=VERSION,
|
||||||
ssh::Bool=false,
|
ssh::Bool=false,
|
||||||
|
manifest::Bool=false,
|
||||||
plugins::Vector{<:Plugin}=Plugin[],
|
plugins::Vector{<:Plugin}=Plugin[],
|
||||||
)
|
)
|
||||||
# Check for required Git options for package generation
|
# Check for required Git options for package generation
|
||||||
@ -79,7 +82,7 @@ create a template, you can use [`interactive_template`](@ref) instead.
|
|||||||
@warn "Plugin list contained duplicates, only the last of each type was kept"
|
@warn "Plugin list contained duplicates, only the last of each type was kept"
|
||||||
end
|
end
|
||||||
|
|
||||||
new(user, host, license, authors, dir, julia_version, ssh, plugin_dict)
|
new(user, host, license, authors, dir, julia_version, ssh, manifest, plugin_dict)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -101,6 +104,7 @@ function Base.show(io::IO, t::Template)
|
|||||||
println(io, "$spc→ Package directory: $(replace(maybe(t.dir), homedir() => "~"))")
|
println(io, "$spc→ Package directory: $(replace(maybe(t.dir), homedir() => "~"))")
|
||||||
println(io, "$spc→ Minimum Julia version: v$(version_floor(t.julia_version))")
|
println(io, "$spc→ Minimum Julia version: v$(version_floor(t.julia_version))")
|
||||||
println(io, "$spc→ SSH remote: $(t.ssh ? "Yes" : "No")")
|
println(io, "$spc→ SSH remote: $(t.ssh ? "Yes" : "No")")
|
||||||
|
println(io, "$spc→ Commit Manifest.toml: $(t.manifest ? "Yes" : "No")")
|
||||||
|
|
||||||
print(io, "$spc→ Plugins:")
|
print(io, "$spc→ Plugins:")
|
||||||
if isempty(t.plugins)
|
if isempty(t.plugins)
|
||||||
@ -130,7 +134,7 @@ function interactive_template(; fast::Bool=false)
|
|||||||
kwargs = Dict{Symbol, Any}()
|
kwargs = Dict{Symbol, Any}()
|
||||||
|
|
||||||
default_user = LibGit2.getconfig("github.user", "")
|
default_user = LibGit2.getconfig("github.user", "")
|
||||||
print("Enter your username [$(isempty(default_user) ? "REQUIRED" : default_user)]: ")
|
print("Username [$(isempty(default_user) ? "REQUIRED" : default_user)]: ")
|
||||||
user = readline()
|
user = readline()
|
||||||
kwargs[:user] = if !isempty(user)
|
kwargs[:user] = if !isempty(user)
|
||||||
user
|
user
|
||||||
@ -144,7 +148,7 @@ function interactive_template(; fast::Bool=false)
|
|||||||
"https://github.com"
|
"https://github.com"
|
||||||
else
|
else
|
||||||
default_host = "github.com"
|
default_host = "github.com"
|
||||||
print("Enter the code hosting service [$default_host]: ")
|
print("Code hosting service [$default_host]: ")
|
||||||
host = readline()
|
host = readline()
|
||||||
isempty(host) ? default_host : host
|
isempty(host) ? default_host : host
|
||||||
end
|
end
|
||||||
@ -152,7 +156,7 @@ function interactive_template(; fast::Bool=false)
|
|||||||
kwargs[:license] = if fast
|
kwargs[:license] = if fast
|
||||||
"MIT"
|
"MIT"
|
||||||
else
|
else
|
||||||
println("Select a license:")
|
println("License:")
|
||||||
io = IOBuffer()
|
io = IOBuffer()
|
||||||
available_licenses(io)
|
available_licenses(io)
|
||||||
licenses = ["" => "", collect(LICENSES)...]
|
licenses = ["" => "", collect(LICENSES)...]
|
||||||
@ -169,7 +173,7 @@ function interactive_template(; fast::Bool=false)
|
|||||||
else
|
else
|
||||||
default_authors = LibGit2.getconfig("user.name", "")
|
default_authors = LibGit2.getconfig("user.name", "")
|
||||||
default_str = isempty(default_authors) ? "None" : default_authors
|
default_str = isempty(default_authors) ? "None" : default_authors
|
||||||
print("Enter the package author(s) [$default_str]: ")
|
print("Package author(s) [$default_str]: ")
|
||||||
authors = readline()
|
authors = readline()
|
||||||
isempty(authors) ? default_authors : authors
|
isempty(authors) ? default_authors : authors
|
||||||
end
|
end
|
||||||
@ -178,7 +182,7 @@ function interactive_template(; fast::Bool=false)
|
|||||||
Pkg.devdir()
|
Pkg.devdir()
|
||||||
else
|
else
|
||||||
default_dir = Pkg.devdir()
|
default_dir = Pkg.devdir()
|
||||||
print("Enter the path to the package directory [$default_dir]: ")
|
print("Path to package directory [$default_dir]: ")
|
||||||
dir = readline()
|
dir = readline()
|
||||||
isempty(dir) ? default_dir : dir
|
isempty(dir) ? default_dir : dir
|
||||||
end
|
end
|
||||||
@ -187,7 +191,7 @@ function interactive_template(; fast::Bool=false)
|
|||||||
VERSION
|
VERSION
|
||||||
else
|
else
|
||||||
default_julia_version = VERSION
|
default_julia_version = VERSION
|
||||||
print("Enter the minimum Julia version [$(version_floor(default_julia_version))]: ")
|
print("Mminimum Julia version [$(version_floor(default_julia_version))]: ")
|
||||||
julia_version = readline()
|
julia_version = readline()
|
||||||
isempty(julia_version) ? default_julia_version : VersionNumber(julia_version)
|
isempty(julia_version) ? default_julia_version : VersionNumber(julia_version)
|
||||||
end
|
end
|
||||||
@ -196,10 +200,17 @@ function interactive_template(; fast::Bool=false)
|
|||||||
false
|
false
|
||||||
else
|
else
|
||||||
print("Set remote to SSH? [no]: ")
|
print("Set remote to SSH? [no]: ")
|
||||||
in(uppercase(readline()), ["Y", "YES", "T", "TRUE"])
|
uppercase(readline()) in ["Y", "YES", "T", "TRUE"]
|
||||||
end
|
end
|
||||||
|
|
||||||
println("Select plugins:")
|
kwargs[:manifest] = if fast
|
||||||
|
false
|
||||||
|
else
|
||||||
|
print("Commit Manifest.toml? [no]: ")
|
||||||
|
uppercase(readline()) in ["Y", "YES", "T", "TRUE"]
|
||||||
|
end
|
||||||
|
|
||||||
|
println("Plugins:")
|
||||||
# Only include plugin types which have an `interactive` method.
|
# Only include plugin types which have an `interactive` method.
|
||||||
plugin_types = filter(t -> hasmethod(interactive, (Type{t},)), fetch(plugin_types))
|
plugin_types = filter(t -> hasmethod(interactive, (Type{t},)), fetch(plugin_types))
|
||||||
type_names = map(t -> split(string(t), ".")[end], plugin_types)
|
type_names = map(t -> split(string(t), ".")[end], plugin_types)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
@testset "Interactive mode" begin
|
@testset "Interactive mode" begin
|
||||||
@testset "Template creation" begin
|
@testset "Template creation" begin
|
||||||
write(stdin.buffer, "$me\n\n\r\n\n\nd")
|
write(stdin.buffer, "$me\n\n\r\n\n\n\nd")
|
||||||
t = interactive_template()
|
t = interactive_template()
|
||||||
@test t.user == me
|
@test t.user == me
|
||||||
@test t.host == "github.com"
|
@test t.host == "github.com"
|
||||||
@ -17,7 +17,7 @@
|
|||||||
end
|
end
|
||||||
|
|
||||||
down = '\x1b' * "[B" # Down array key.
|
down = '\x1b' * "[B" # Down array key.
|
||||||
write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\n$down\r$down\rd\n\n")
|
write(stdin.buffer, "$me\ngitlab.com\n$down\r$me\n$test_file\n0.5\nyes\nyes\n$down\r$down\rd\n\n")
|
||||||
t = interactive_template()
|
t = interactive_template()
|
||||||
@test t.user == me
|
@test t.user == me
|
||||||
@test t.host == "gitlab.com"
|
@test t.host == "gitlab.com"
|
||||||
@ -27,6 +27,7 @@
|
|||||||
@test t.dir == abspath(test_file)
|
@test t.dir == abspath(test_file)
|
||||||
@test t.julia_version == v"0.5.0"
|
@test t.julia_version == v"0.5.0"
|
||||||
@test t.ssh
|
@test t.ssh
|
||||||
|
@test t.manifest
|
||||||
# Like above, not sure which plugins this will generate.
|
# Like above, not sure which plugins this will generate.
|
||||||
@test length(t.plugins) == 2
|
@test length(t.plugins) == 2
|
||||||
|
|
||||||
@ -39,12 +40,13 @@
|
|||||||
@test t.dir == default_dir
|
@test t.dir == default_dir
|
||||||
@test t.julia_version == VERSION
|
@test t.julia_version == VERSION
|
||||||
@test !t.ssh
|
@test !t.ssh
|
||||||
|
@test !t.manifest
|
||||||
@test isempty(t.plugins)
|
@test isempty(t.plugins)
|
||||||
println()
|
println()
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Package generation" begin
|
@testset "Package generation" begin
|
||||||
write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\nd")
|
write(stdin.buffer, "$me\n\n\r\n\n\n\n\n\n\nd")
|
||||||
generate_interactive(test_pkg; gitconfig=gitconfig)
|
generate_interactive(test_pkg; gitconfig=gitconfig)
|
||||||
@test isdir(joinpath(default_dir, test_pkg))
|
@test isdir(joinpath(default_dir, test_pkg))
|
||||||
rm(joinpath(default_dir, test_pkg); force=true, recursive=true)
|
rm(joinpath(default_dir, test_pkg); force=true, recursive=true)
|
||||||
|
@ -45,6 +45,8 @@ write(test_file, template_text)
|
|||||||
@test t.authors == LibGit2.getconfig("user.name", "")
|
@test t.authors == LibGit2.getconfig("user.name", "")
|
||||||
@test t.dir == default_dir
|
@test t.dir == default_dir
|
||||||
@test t.julia_version == VERSION
|
@test t.julia_version == VERSION
|
||||||
|
@test !t.ssh
|
||||||
|
@test !t.manifest
|
||||||
@test isempty(t.plugins)
|
@test isempty(t.plugins)
|
||||||
|
|
||||||
# Checking non-default field assignments.
|
# Checking non-default field assignments.
|
||||||
@ -72,6 +74,12 @@ write(test_file, template_text)
|
|||||||
t = Template(; user=me, julia_version=v"0.1.2")
|
t = Template(; user=me, julia_version=v"0.1.2")
|
||||||
@test t.julia_version == v"0.1.2"
|
@test t.julia_version == v"0.1.2"
|
||||||
|
|
||||||
|
t = Template(; user=me, ssh=true)
|
||||||
|
@test t.ssh
|
||||||
|
|
||||||
|
t = Template(; user=me, manifest=true)
|
||||||
|
@test t.manifest
|
||||||
|
|
||||||
# The template should contain whatever plugins you give it.
|
# The template should contain whatever plugins you give it.
|
||||||
t = Template(;
|
t = Template(;
|
||||||
user=me,
|
user=me,
|
||||||
@ -114,6 +122,7 @@ end
|
|||||||
→ Package directory: $pkg_dir
|
→ Package directory: $pkg_dir
|
||||||
→ Minimum Julia version: v$(PkgTemplates.version_floor())
|
→ Minimum Julia version: v$(PkgTemplates.version_floor())
|
||||||
→ SSH remote: No
|
→ SSH remote: No
|
||||||
|
→ Commit Manifest.toml: No
|
||||||
→ Plugins: None
|
→ Plugins: None
|
||||||
"""
|
"""
|
||||||
@test text == rstrip(expected)
|
@test text == rstrip(expected)
|
||||||
@ -121,6 +130,7 @@ end
|
|||||||
user=me,
|
user=me,
|
||||||
license="",
|
license="",
|
||||||
ssh=true,
|
ssh=true,
|
||||||
|
manifest=true,
|
||||||
plugins=[
|
plugins=[
|
||||||
TravisCI(),
|
TravisCI(),
|
||||||
Codecov(),
|
Codecov(),
|
||||||
@ -137,6 +147,7 @@ end
|
|||||||
→ Package directory: $pkg_dir
|
→ Package directory: $pkg_dir
|
||||||
→ Minimum Julia version: v$(PkgTemplates.version_floor())
|
→ Minimum Julia version: v$(PkgTemplates.version_floor())
|
||||||
→ SSH remote: Yes
|
→ SSH remote: Yes
|
||||||
|
→ Commit Manifest.toml: Yes
|
||||||
→ Plugins:
|
→ Plugins:
|
||||||
• Codecov:
|
• Codecov:
|
||||||
→ Config file: None
|
→ Config file: None
|
||||||
@ -186,10 +197,7 @@ end
|
|||||||
gen_readme(pkg_dir, t)
|
gen_readme(pkg_dir, t)
|
||||||
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
readme = readchomp(joinpath(pkg_dir, "README.md"))
|
||||||
rm(joinpath(pkg_dir, "README.md"))
|
rm(joinpath(pkg_dir, "README.md"))
|
||||||
@test <(
|
@test findfirst("coveralls", readme).start < findfirst("baz", readme).start
|
||||||
something(findfirst("coveralls", readme)).start,
|
|
||||||
something(findfirst("baz", readme)).start,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Test the gitignore generation.
|
# Test the gitignore generation.
|
||||||
@test gen_gitignore(pkg_dir, t) == [".gitignore"]
|
@test gen_gitignore(pkg_dir, t) == [".gitignore"]
|
||||||
@ -197,11 +205,17 @@ end
|
|||||||
gitignore = read(joinpath(pkg_dir, ".gitignore"), String)
|
gitignore = read(joinpath(pkg_dir, ".gitignore"), String)
|
||||||
rm(joinpath(pkg_dir, ".gitignore"))
|
rm(joinpath(pkg_dir, ".gitignore"))
|
||||||
@test occursin(".DS_Store", gitignore)
|
@test occursin(".DS_Store", gitignore)
|
||||||
|
@test occursin("Manifest.toml", gitignore)
|
||||||
for p in values(t.plugins)
|
for p in values(t.plugins)
|
||||||
for entry in p.gitignore
|
for entry in p.gitignore
|
||||||
@test occursin(entry, gitignore)
|
@test occursin(entry, gitignore)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
t = Template(; user=me, manifest=true)
|
||||||
|
@test gen_gitignore(pkg_dir, t) == [".gitignore", "Manifest.toml"]
|
||||||
|
gitignore = read(joinpath(pkg_dir, ".gitignore"), String)
|
||||||
|
@test !occursin("Manifest.toml", gitignore)
|
||||||
|
rm(joinpath(pkg_dir, ".gitignore"))
|
||||||
|
|
||||||
# Test the license generation.
|
# Test the license generation.
|
||||||
@test gen_license(pkg_dir, t) == ["LICENSE"]
|
@test gen_license(pkg_dir, t) == ["LICENSE"]
|
||||||
@ -219,7 +233,7 @@ end
|
|||||||
rm(joinpath(pkg_dir, "REQUIRE"))
|
rm(joinpath(pkg_dir, "REQUIRE"))
|
||||||
|
|
||||||
# Test the test generation.
|
# Test the test generation.
|
||||||
@test gen_tests(pkg_dir, t) == ["Manifest.toml", "test/"]
|
@test gen_tests(pkg_dir, t) == ["test/"]
|
||||||
@test isfile(joinpath(pkg_dir, "Project.toml"))
|
@test isfile(joinpath(pkg_dir, "Project.toml"))
|
||||||
project = read(joinpath(pkg_dir, "Project.toml"), String)
|
project = read(joinpath(pkg_dir, "Project.toml"), String)
|
||||||
@test occursin("[extras]\nTest = ", project)
|
@test occursin("[extras]\nTest = ", project)
|
||||||
@ -285,6 +299,26 @@ end
|
|||||||
generate(test_pkg, t; gitconfig=gitconfig)
|
generate(test_pkg, t; gitconfig=gitconfig)
|
||||||
@test isdir(joinpath(temp_dir, test_pkg))
|
@test isdir(joinpath(temp_dir, test_pkg))
|
||||||
rm(temp_dir; recursive=true)
|
rm(temp_dir; recursive=true)
|
||||||
|
|
||||||
|
# Check that the Manifest.toml is not commited by default.
|
||||||
|
t = Template(; user=me)
|
||||||
|
generate(test_pkg, t; gitconfig=gitconfig)
|
||||||
|
@test occursin("Manifest.toml", read(joinpath(pkg_dir, ".gitignore"), String))
|
||||||
|
# I'm not sure this is the "right" way to do this.
|
||||||
|
repo = GitRepo(pkg_dir)
|
||||||
|
idx = LibGit2.GitIndex(repo)
|
||||||
|
@test findall("Manifest.toml", idx) === nothing
|
||||||
|
rm(pkg_dir; recursive=true)
|
||||||
|
|
||||||
|
# And that it is when you tell it to be.
|
||||||
|
t = Template(; user=me, manifest=true)
|
||||||
|
generate(test_pkg, t; gitconfig=gitconfig)
|
||||||
|
@test !occursin("Manifest.toml", read(joinpath(pkg_dir, ".gitignore"), String))
|
||||||
|
# I'm not sure this is the "right" way to do this.
|
||||||
|
repo = GitRepo(pkg_dir)
|
||||||
|
idx = LibGit2.GitIndex(repo)
|
||||||
|
@test findall("Manifest.toml", idx) !== nothing
|
||||||
|
rm(pkg_dir; recursive=true)
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Version floor" begin
|
@testset "Version floor" begin
|
||||||
|
Loading…
Reference in New Issue
Block a user