hrbrmstr/cloc

is cloc_git by commit supposed to already work?

Opened this issue · 13 comments

I get a bug using it 😢 but understand if it's not implemented yet!

aye, it should work:

library(cloc)
getwd()
## [1] "/Users/hrbrmstr/packages/hrbrthemes"

cloc_git(".", "4ea652b9ccee7cecec394eaa4a765ff975235e9b")
## # A tibble: 6 x 10
##   source   language file_count file_count_pct   loc     loc_pct blank_lines
##    <chr>      <chr>      <int>          <dbl> <int>       <dbl>       <int>
## 1      .       HTML         21     0.43750000  2556 0.656563062         620
## 2      .          R         17     0.35416667   807 0.207295145         157
## 3      .   Markdown          4     0.08333333   247 0.063447213          74
## 4      .        CSS          2     0.04166667   230 0.059080401          60
## 5      .       YAML          2     0.04166667    40 0.010274852           9
## 6      . JavaScript          2     0.04166667    13 0.003339327           1
## # ... with 3 more variables: blank_line_pct <dbl>, comment_lines <int>,
## #   comment_line_pct <dbl>

cloc_git(".", "b2ce784686e8368c7163a75cc417b318d9a45379")
## # A tibble: 6 x 10
##   source   language file_count file_count_pct   loc     loc_pct blank_lines
##    <chr>      <chr>      <int>          <dbl> <int>       <dbl>       <int>
## 1      .       HTML         21     0.41176471  2556 0.628318584         620
## 2      .          R         19     0.37254902   920 0.226155359         180
## 3      .   Markdown          4     0.07843137   305 0.074975418          83
## 4      .        CSS          2     0.03921569   230 0.056538840          60
## 5      .       YAML          3     0.05882353    44 0.010816126           9
## 6      . JavaScript          2     0.03921569    13 0.003195674           1
## # ... with 3 more variables: blank_line_pct <dbl>, comment_lines <int>,
## #   comment_line_pct <dbl>

It might just be an issue with my horribad documentation :-)

Oh my maybe I'm using hash instead of identifier 😱🙈

Oh actually sha=identifier?! I get this error

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 1 did not have 5 elements

If I print dat (yes my debugging methods could be better) when using

I get

``` r
> getwd()
[1] "C:/Users/Maelle/Documents/cloc"
> cloc::cloc_git(getwd(), "3643cd09d4b951b1b35d32dffe35985dfe7756c4")
[1] ""                                                         
[2] "1 error:"                                                 
[3] "Unable to read:  3643cd09d4b951b1b35d32dffe35985dfe7756c4"
 Show Traceback
 
 Rerun with Debug
 Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  : 
  line 1 did not have 5 elements 

doing the same…one sec

setwd("~/packages/cloc")

getwd()
## [1] "/Users/hrbrmstr/packages/cloc"

cloc::cloc_git(getwd(), "3643cd09d4b951b1b35d32dffe35985dfe7756c4")
## # A tibble: 4 x 10
##   source language file_count file_count_pct   loc      loc_pct blank_lines blank_line_pct
##    <chr>    <chr>      <int>          <dbl> <int>        <dbl>       <int>          <dbl>
## 1   cloc     Perl          1          0.125 10059 0.9880168942         787    0.933570581
## 2   cloc Markdown          2          0.250    60 0.0058933307          31    0.036773428
## 3   cloc        R          4          0.500    52 0.0051075533          22    0.026097272
## 4   cloc     YAML          1          0.125    10 0.0009822218           3    0.003558719
## # ... with 2 more variables: comment_lines <int>, comment_line_pct <dbl>setwd("~/packages/cloc")

I'll be able to fire up windows here later tonight and see if it's something related to Windows file system ops and the perl script and i shld try to have this fail more gracefully anyway so tis a good find regardless.

Do you think one could use git2r to create a copy of the repo as it was at that commit and then run cloc on it? I will need to do such a copy to look at the NAMESPACE at a given commit anyway.

i have been able to replicate the issue (i get a diff error) on Windows and may have a workaround soon. interestingly enough it works from an RStudio Terminal and from CMD.EXE so it's likely a problem with the system() call (that I'll switch over to processx in a bit).

Cool!

For my current use case I am git resetting hard at the commit bc I need to parse the NAMESPACE at that commit too so it is just easiee 😁

hrm. still getting unable to read the specific commit tag. will keep poking

hrm. mebbe this? AlDanial/cloc#252

ah in this case better to wait and suggest the approach of copying and git resetting?

it'll now clone remote repos provided they are specified like they are for devtools (git://)