R/git_commit.R

Defines functions git_commit

Documented in git_commit

#' Push a local repo to remote MSK KMI Enterprise GitHub repository
#' @param path_to_local_repo full path to local repository to be pushed
#' @param commit_message message to be included in the commit
#' @importFrom typewriteR tell_me
#' @importFrom crayon yellow
#' @export


git_commit <-
        function(path_to_local_repo, commit_message, description = NULL) {
                if (is.null(description)) {
                        if (dir.exists(path_to_local_repo)) {
                                system(paste0("cd\n",
                                              "cd ", path_to_local_repo,"\n",
                                              "git commit -m '", commit_message, "'"
                                )
                                )
                        } else {
                                typewriteR::tell_me(crayon::yellow("\tError: Local repository", path_to_local_repo, "does not exist."))
                        }
                } else {
                        if (dir.exists(path_to_local_repo)) {
                                system(paste0("cd\n",
                                              "cd ", path_to_local_repo,"\n",
                                              "git commit -m '", commit_message, "' ", "-m '", description, "'"
                                )
                                )
                        } else {
                                typewriteR::tell_me(crayon::yellow("\tError: Local repository", path_to_local_repo, "does not exist."))
                        }
                }
        }
patelm9/mirCat documentation built on April 24, 2020, 6:24 p.m.