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

Error: Could not find git root. #1

Open
hsonne opened this issue Jul 8, 2018 · 7 comments
Open

Error: Could not find git root. #1

hsonne opened this issue Jul 8, 2018 · 7 comments
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@hsonne
Copy link
Member

hsonne commented Jul 8, 2018

Running the following code leads to the error shown below:

devtools::install_github("KWB-R/kwb.pkgbuild")
temp_pkg <- "~/RProgramming/github/kwb.code"
usethis::create_package(path = temp_pkg,open = FALSE)
fs::file_delete(path = file.path(temp_pkg, "DESCRIPTION"))
author <- list(name = "Hauke Sonnenberg", orcid = "0000-0001-9134-2871")
pkg <- list(
  name = "kwb.code", 
  title = "Analyse Your R Code!", 
  desc  = "This package allows you to parse your R scripts and to calculate some staticstics on your code."
)
setwd(temp_pkg)
kwb.pkgbuild::use_pkg(
  author, pkg, version = "0.1.0.9000", stage = "experimental"
)

Output:

Creating KWB DESCRIPTION file....
✔ Writing 'DESCRIPTION'
Creating DESCRIPTION file....done.
Creating KWB MIT LICENSE file....
✔ Writing 'LICENSE.md'
✔ Adding '^LICENSE\\.md$' to '.Rbuildignore'
✔ Writing 'LICENSE'
Creating MIT LICENSE file....done.
● Modify '_pkgdown.yml'
✔ Adding '^_pkgdown\\.yml$' to '.Rbuildignore'
✔ Creating 'docs/'
✔ Adding '^docs$' to '.Rbuildignore'
trying URL 'https://raw.githubusercontent.com/tidyverse/readxl/5649e2643d25bb5b6353797fc48bbcbb0eb72f6d/appveyor.yml'
Content type 'text/plain; charset=utf-8' length 860 bytes
==================================================
downloaded 860 bytes

✔ Adding 'covr' to Suggests field in DESCRIPTION
✔ Writing 'codecov.yml'
✔ Adding '^codecov\\.yml$' to '.Rbuildignore'
Error: Could not find git root.
@hsonne hsonne added the bug Something isn't working label Jul 8, 2018
@hsonne
Copy link
Member Author

hsonne commented Jul 8, 2018

@mrustl The error comes out of use_codecov()

@hsonne
Copy link
Member Author

hsonne commented Jul 8, 2018

@mrustl The error comes out of use_codecov_badge()

@hsonne
Copy link
Member Author

hsonne commented Jul 8, 2018

The error comes out of gh:::repo_root(). I need to init a git repository first in the directory. Is this described in the tutorial? When should I do it? Or should I first create the repo on github, checkout to a local folder and then run your function passing the path to that folder? Should be described in the tutorial!

@mrustl
Copy link
Member

mrustl commented Jul 9, 2018

I also didn't create a github repo first. But the error doesn`t matter (for me) as it only leads to not creating the coverage badge.
from usethis (v.1.3.0)

use_codecov_badge <- function () 
{
    gh <- gh::gh_tree_remote(proj_get())
    url <- paste0("https://codecov.io/github/", gh$username, 
        "/", gh$repo, "?branch=master")
    img <- file.path("https://codecov.io/gh", gh$username, gh$repo, 
        "branch/master/graph/badge.svg")
    use_badge("Coverage status", url, img)
}

I am dont sure whether this ERROR is already fixed in the latest Github version of usethis as there is now a little different code for this function in usethis (v.1.3.0.9000)

use_codecov_badge <- function () 
{
use_codecov_badge <- function() {
  check_uses_github()
  url <- glue("https://codecov.io/github/{github_repo_spec()}?branch=master")
  img <- glue(
    "https://codecov.io/gh/{github_repo_spec()}/branch/master/graph/badge.svg"
  )
  use_badge("Coverage status", url, img)
}

Source: https://github.com/r-lib/usethis/blob/b459a9f1875bfb8eeee2e9d2941dcb7203d6478e/R/ci.R

In any case: the error caused being not a GIT repo in usethis (v.1.3.0) is not relevant for us as in kwb.pkgbuild the badge creation is performed during the README .(R)md build, which uses my own functions for creating the badges (see here).

@mrustl
Copy link
Member

mrustl commented Jul 9, 2018

Furthermore the workflow demanded by the usethis package (first needs to be Git(hub) repository) does not really fit with what we usually do at KWB (e.g first develop internally, then publish on Github). In addition for following the usethis workflow the installation of GIT would be mandatory.

Using the "bug" in kwb.pkgdown is much more inclusive because you can safely ignore the error!

@mrustl mrustl added the wontfix This will not be worked on label Jul 9, 2018
@mrustl
Copy link
Member

mrustl commented Jul 11, 2018

@hsonne the codecov badge creation ERROR does not occur in case you apply the following workflow:

  1. Create an empty Github repo
  2. Checkout this repo
  3. Run kwb.pkgbuild::use_pkg()

fix_codecov_error

  1. Done

@hsonne
Copy link
Member Author

hsonne commented Jul 11, 2018

@mrustl I know. I did it like that with kwb.readxl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants