-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Respect .gitignore #49
Comments
As a workaround, this can work:
...as long as you don't have spaces in your path. A bit cumbersome, though. |
also, maybe this might be as simple as having a flag to read filenames from stdin?
|
You can use xargs too, shorter than adding an option no one will remember to read file names from stdin:
|
wouldnt that suffer from the spaces problem too? |
First of all, my apologies, I did miss that point; I'm quite tired at the moment. However, how do you propose that the As a work around for this particular case, |
(I do agree that adding support for .gitignore and other VCS ignore files is certainly worthwhile, however.) |
I first started looking at obeying .gitignore in July 2015. The more I looked, the less fun it seemed to implement. Yes, it would be a nice feature. I'll certainly entertain pull requests. However, until I have a burst of enthusiasm about this problem, implementation is a ways off. If anyone is interested in moving this along, we can tackle this independently of cloc, that is to say, given a stand-alone solution, I'll handle integrating it into cloc. The problem can be reduced to this: given a text file containing a sorted directory tree (eg the output of |
Language preference for said implementation? (To be clear, I'm not necessarily volunteering, I am so slammed right now, Also, would it make sense to rely on the VCS to determine what to include On Fri, Jan 15, 2016 at 11:54 PM AlDanial notifications@github.com wrote:
|
Ideally the implementation would be in Python or Perl, but bash is plenty good enough. Re: relying on an external VCS--that's what the "git ls-files" work-around earlier in the thread is all about. I'm not keen on making cloc do system calls unless there's no other way to do it (cloc currently does system calls to archive tools like tar and zip). |
I get the desire to avoid system calls, but that means much more code will be needed, and less duplication between VCSs. Also, it complicates the user's interaction: Is cloc expected to respect settings in global VCS config files? How does cloc find these? Otherwise |
I guess an alternative implementation would be to explicitly pass the ignore file to
|
Or perhaps Again I'm not keen on the system calls but am coming around to the thinking that this may be the right solution here. The documentation will explicitly state that whatever the user puts in quotes will be invoked as a system call and the output treated as a list of files for cloc to consider. Subsequent filters like |
I like that. I've hacked up a script that looks like this: # git-cloc
git ls-files $* | \
grep -v -E '(coverage|log|tmp|temp|vendor|fixture|fixtures|dist|cassettes)/' | \
tr '\n' '\0' | \
xargs -0 cloc ... to be able to use |
The way I do this personally is by pushing to remote ( Example (
It's not pretty, but it's certainly a reasonable workaround. |
That's a nice tip, thanks. My planned implementation will hopefully be more simple (namely a single step) but |
Cool, thanks. On Mon, Feb 15, 2016 at 11:47 PM AlDanial notifications@github.com wrote:
|
Hi guys, I had exactly this problem today (counting line of codes in a git repo) and came across this issue. As said earlier in this discussion
works like a charm, except with files containing a space in their name. However, that seems to work, even with spaces in names:
So, +1 for the idea of @rstacruz: juste be able to pass file list via stdin. Parsing .gitignore, communicating with vcs or anything in this direction doesn't seem like the job of cloc to me. |
That is, in fact, how I plan to implement This coming Friday I'll have time to implement this. |
any user provided file name generator; issue #49
Git commit 55e616e on the master branch implements |
Also: if you crank the verbose level to 2 (with I don't know of git repos that have files with spaces in them but I don't expect these to be an issue. |
Tested with Works great, thank you very much! |
neat! curious:
considering not that i suggest you take that route (imho outsourcing the work to |
It's a matter of practicality. The time I have to work on cloc is quite limited. I'd weighed different approaches to parsing .gitignore for six months (July-Dec. 2015) without progress. Other requests for new language support and bug fixes naturally keep coming in and must be attended to. Bottom line was that I saw no feasible alternative to doing the system calls. @mbovel -- thanks for testing! |
The latest release of cloc is 1.70, haven't gotten to 2.0 yet. cloc --version it will tell you which version you're using. Get the latest release from https://github.com/AlDanial/cloc/releases On Fri, Jul 15, 2016 at 11:16 AM, Fernando Montoya <notifications@github.com
|
First off, @AlDanial thanks for making and maintaining
Run |
Good tip, thanks; as a git novice I continue to be surprised by git's power and flexibility. If you haven't tried it already, cloc --vcs git should do the same thing. |
@suweller I've tried with no success
Any idea why? throws:
While running it directly does work |
Both methods work for me now so I can't reproduce your error. |
This is sufficient. Just putting it in for the next time I need to search for it ;-)
|
I'm not sure if this was ever filed, but it'd be nice to have .gitignore respected. is that possible?
The text was updated successfully, but these errors were encountered: