Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use_git() should make an initial commit, if necessary #852

Closed
llrs opened this issue Jul 23, 2019 · 3 comments · Fixed by #1049
Closed

use_git() should make an initial commit, if necessary #852

llrs opened this issue Jul 23, 2019 · 3 comments · Fixed by #1049
Labels
bug git

Comments

@llrs
Copy link
Contributor

@llrs llrs commented Jul 23, 2019

TLDR:Use_git doesn't make the initial commit if the project is started already with git from Rstudio

I started a new package following the Rstudio new project > R package > git then I used some of the usethis functions to set up the package.

The history of command run is:

use_rstudio()
use_git()
use_mit_license()
use_testthat()
use_package("package")
desc::desc_normalize()
use_readme_rmd()
use_travis() # Error shown below
use_github()
use_coverage()
use_vignette("name")
?use_github
git_sitrep() # Sitrep shown below

However it failed:
different commands that relay on github remote
Despite having correctly setup the git configuration, see the git_sitrep:
Result of git_sitrep

The problem comes from use_github, which expects to find a branch. But the branch is not created in use_git because Rstudio already created the repository and then use_git doesn't continue and commit the "Initial commit".

A solution would be to check if there is any committed file by checking the repository head. This involves the line

if (uses_git()) {
.

Which could be adapted to check if there is any committed file or any branch.

@jennybc
Copy link
Member

@jennybc jennybc commented Jul 23, 2019

I'll be doing a lot of "git renovation" here, probably before the next CRAN release. So I'll deal with this then.

@jennybc jennybc changed the title use_git and initiating a project from Rstudio with git use_git() should make an initial commit, if necessary Jul 23, 2019
@jennybc jennybc added bug git labels Jul 23, 2019
@llrs
Copy link
Contributor Author

@llrs llrs commented Jul 23, 2019

Great to hear that (I suppose that this is specially difficult for newcomers who are not sure which guidelines follow so I hope it can be fixed soon).

@hadley
Copy link
Member

@hadley hadley commented Mar 14, 2020

Minimal reprex:

library(usethis)
options(usethis.quiet = TRUE)

path <- create_package(tempfile())
proj_set(path)
git2r::init(proj_get())
#> Local:    /private/tmp/RtmpYSF5zd/file1414c75b8d944
#> Head:     nothing commited (yet)
use_git()
use_github()
#> Error: Detached head; can't continue

Created on 2020-03-14 by the reprex package (v0.3.0)

hadley added a commit that referenced this issue Mar 14, 2020
1. Initialise repo
2. Perform initial commit

Fixes #852
hadley added a commit that referenced this issue Mar 18, 2020
1. Initialise repo
2. Perform initial commit

Fixes #852
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug git
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants