Skip to content

Commit 23ca188

Browse files
committed
chore: refactor a bit
1 parent f26d505 commit 23ca188

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

R/commit.R

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,11 @@ git_revert <- function(
335335
if (no_commit) {
336336
return(NULL)
337337
}
338-
if (!length(message)) {
339-
info <- git_commit_info(sha, repo = repo)
340-
subject <- strsplit(info$message, "\n")[[1]][1]
341-
subject <- sub("\\s+$", "", subject)
342-
message <- sprintf(
343-
'Revert "%s"\n\nThis reverts commit %s.\n',
344-
subject,
345-
info$id
346-
)
338+
339+
if (is.null(message)) {
340+
message <- revert_message(sha, repo)
347341
}
342+
348343
invisible(git_commit(
349344
message,
350345
author = author,
@@ -358,3 +353,15 @@ assert_string <- function(x) {
358353
stop("Argument must be a string of length 1")
359354
}
360355
}
356+
357+
revert_message <- function(sha, repo) {
358+
info <- git_commit_info(sha, repo = repo)
359+
subject <- strsplit(info$message, "\n")[[1]][1]
360+
subject <- sub("\\s+$", "", subject)
361+
362+
sprintf(
363+
'Revert "%s"\n\nThis reverts commit %s.\n',
364+
subject,
365+
info$id
366+
)
367+
}

0 commit comments

Comments
 (0)