Make git_config author take precedence over default git username

This commit is contained in:
Chris de Graaf 2017-08-14 15:58:01 -05:00
parent 90245a3fba
commit 7634f7fb59
3 changed files with 13 additions and 8 deletions

View File

@ -217,7 +217,7 @@ end
""" """
gen_file(file_path::AbstractString, text::AbstractString) -> Void gen_file(file_path::AbstractString, text::AbstractString) -> Void
Create a new file containing some given text. Create a new file containing some given text. Always ends the file with a newline.
# Arguments # Arguments
* `file::AbstractString`: Path to the file to be created. * `file::AbstractString`: Path to the file to be created.

View File

@ -4,8 +4,8 @@
Show all available license names. Show all available license names.
""" """
function show_license() function show_license()
for k in sort!(collect(keys(LICENSES))) for (k, v) in LICENSES
println("$k: $(LICENSES[k])") println("$k: $v")
end end
end end
@ -19,7 +19,7 @@ Shows the text of a given `license`.
The list of available licenses can be shown with `show_license()`. The list of available licenses can be shown with `show_license()`.
""" """
function show_license(license::AbstractString) function show_license(license::AbstractString)
print(read_license(license)) println(read_license(license))
end end
""" """
@ -34,9 +34,9 @@ Returns the license text.
""" """
function read_license(license::AbstractString) function read_license(license::AbstractString)
path = joinpath(LICENSE_DIR, license) path = joinpath(LICENSE_DIR, license)
if !isfile(path) if isfile(path)
throw(ArgumentError("License '$license' is not available")) return string(readchomp(path))
else else
return readstring(path) throw(ArgumentError("License '$license' is not available"))
end end
end end

View File

@ -45,7 +45,12 @@ Records common information used to generate a package.
throw(ArgumentError("Must specify remote_prefix::AbstractString")) throw(ArgumentError("Must specify remote_prefix::AbstractString"))
end end
years = string(years) years = string(years)
if isa(authors, Array)
# If an explicitly supplied git config contains a name and the author name was not
# explicitly supplied, then take the git config's name as the author name.
if haskey(git_config, "user.name") && authors == LibGit2.getconfig("user.name", "")
authors = get(git_config, "user.name", LibGit2.getconfig("user.name", ""))
elseif isa(authors, Array)
authors = join(authors, ", ") authors = join(authors, ", ")
end end
if !endswith(remote_prefix, "/") if !endswith(remote_prefix, "/")