Skip to content

Commit

Permalink
Add commit{comment,title} options
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jul 13, 2019
1 parent 8d61044 commit 2b9e6f3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function usein(
rev::AbstractString = "HEAD",
commit::Union{Bool, Cmd} = true,
push::Union{Bool, Cmd} = false,
committitle::Union{Nothing, AbstractString} = nothing,
commitcomment::Union{Nothing, AbstractString} = nothing,
)

uppkgid = pkgat(from)
Expand All @@ -70,8 +72,11 @@ function usein(
# `dryrun=true`:
downroot = strip(read(git_cmd(`rev-parse --show-toplevel`, downpath), String))
commitfiles = relpath.(manifests, downroot)
msg = commitmessage(fullrev, uppkgid, from)
msg = commitmessage(fullrev, uppkgid, from, committitle, commitcomment)
commitargs = `commit --message $msg`
if !(committitle === nothing && commitcomment === nothing)
commitargs = `$commitargs --allow-empty`
end
if commit isa Cmd
commitargs = `$commitargs $commit`
end
Expand Down Expand Up @@ -106,7 +111,7 @@ function usein(
@info "Updating $path"
update_manifest(path, uppkgid, treesha1)
end
if git_is_clean(downpath)
if git_is_clean(downpath) && committitle === nothing && commitcomment === nothing
@info "No updates were required in `$downpath`."
return
end
Expand Down
9 changes: 5 additions & 4 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ vcslinktoroot(args...; kwargs...) =
vcslinktocommit(args...; kwargs...) =
pyimport("vcslinks").commit(args...; kwargs...)

function commitmessage(fullrev, uppkgid::PkgId, from)
function commitmessage(fullrev, uppkgid::PkgId, from, title, comment)
link = vcslinktocommit(fullrev, path=from)
subject = strip(read(git_cmd(`show --format=format:%s --no-patch`, from), String))
return """
Update: $(uppkgid.name)
title = rstrip(something(title, "Update: $(uppkgid.name)"))
comment = rstrip(something(comment, ""))
footer = """
Using commit:
$subject
$link
"""
return join([title, comment, footer], "\n\n")
end

function _is_api(f)
Expand Down

0 comments on commit 2b9e6f3

Please sign in to comment.