R/depreciated/commit_work.R

Defines functions commit_work

#' Commit the current work.
#'
#' @author Jiaxiang Li
#'
#' @import rstudioapi
#' @import stringr
#' @importFrom git2r repository add commit
#' @import fs
#' @import dplyr
#' @import purrr
#' @export

commit_work <- function(){
    repo <- git2r::repository(getwd())
    git2r::add(repo, ".")
    commit_text <- selected()

    ################################################################################
    # is there large files?
    ################################################################################

    # length_large_files <-
    #     fs::dir_info(".",recursive = T) %>%
    #     dplyr::arrange(dplyr::desc(size)) %>%
    #     dplyr::filter(size > '50MB') %>%
    #     nrow()
    # if (length_large_files > 0) {
    #     stop('There is large file(s). Please deal with it before push github.')
    # }

    if (commit_text != '') {
        git2r::commit(repo, commit_text)
    } else {
        rstudioapi::showDialog(title = "Warning",
                               message = "Your clipboard or selected content is emtry, try something."
                               )
    }
    cat(
        sep="\n"
        ,'Git: Commit: '
        ,commit_text
        ,tips()
    )
}
JiaxiangBU/add2md documentation built on Jan. 31, 2020, 7:46 p.m.