Skip to content

Commit 316bdc2

Browse files
committed
fixed pain points in the git create fxn
dont fail on nothign to comimt dont dail on remote already added refresh gist metadata after pushing #39, #31, #32
1 parent b189685 commit 316bdc2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: R/gist_create_git.R

+7-5
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ gist_create_git <- function(files = NULL, description = "", public = TRUE, brows
9090
# add files
9191
git2r::add(git, basename(allfiles))
9292
# commit files
93-
git2r::commit(git, message = "added files from gistr")
93+
cm <- tryCatch(git2r::commit(git, message = "added files from gistr"), error = function(e) e)
94+
if (is(cm, "error")) message(strsplit(cm$message, ":")[[1]][[2]])
9495
# create gist
95-
gst <- cgist(description, public)
96-
gst <- as.gist(gst)
96+
gst <- as.gist(cgist(description, public))
9797
# add remote
98-
git2r::remote_add(git, "gistr", sprintf("git@gist.github.com:/%s.git", gst$id))
98+
ra <- tryCatch(git2r::remote_add(git, "gistr", sprintf("git@gist.github.com:/%s.git", gst$id)), error = function(e) e)
99+
if (is(ra, "error")) message(strsplit(ra$message, ":")[[1]][[2]])
99100
# push up files
100101
git2r::push(git, "gistr", "refs/heads/master", force = TRUE)
101-
# .Call(git2r:::git2r_push, git, "gistr", "+refs/heads/master:refs/heads/master", NULL)
102+
# refresh gist metadata
103+
gst <- gist(gst$id)
102104
# browse
103105
if (browse) browse(gst)
104106
return( gst )

0 commit comments

Comments
 (0)