You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by "Vigo, Nestor" <Ne...@pearson.com> on 2006/08/11 18:30:26 UTC

Source code lines counter

Are there any way to count source code lines that are included under a tag
in Subversion?

Any help will be greatly apprecited.

Kind regards.

**************************************************************************** 
This email may contain confidential material. 
If you were not an intended recipient, 
Please notify the sender and delete all copies. 
We may monitor email to and from our network. 
****************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Source code lines counter

Posted by Blair Zajac <bl...@orcaware.com>.
Bart Robinson wrote:
> On 2006-8-11 Blair Zajac <bl...@orcaware.com> wrote:
>  > Noah Slater wrote:
>  > > Vigo,
>  > > 
>  > > You can run this on *nix based systems:
>  > > 
>  > > $ find . -type f | xargs cat | wc -l
>  > 
>  > You do want to prune the .svn directories and handle names with whitespace in it:
>  > 
>  > find . -name .svn -prune -o -type f -print0 | xargs -0 cat | wc -l
>  > 
>  > If you don't mind seeing the line counts for each file and run a little faster:
>  > 
>  > find . -name .svn -prune -o -type f -print0 | xargs -0 wc -l
> 
> You have to be careful interpreting the results of that last one
> when you have a large number of files because xargs may invoke
> your command more than once due to the system argv size limit
> (see sysconf(3)).  Your output may look like:
> 
>   938 file1
>   . . .
>   123 fileN
> 21232 total    (probably won't see this whiz by...)
>   234 fileN+1
>   . . .
>  3434 fileN+M
> 34343 total    (...and will think this is the actual total)
> 
> -- bart

Good point.  Using xargs cat | wc -l would then be better.

Regards,
Blair

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Source code lines counter

Posted by Bart Robinson <lo...@pobox.com>.
On 2006-8-11 Blair Zajac <bl...@orcaware.com> wrote:
 > Noah Slater wrote:
 > > Vigo,
 > > 
 > > You can run this on *nix based systems:
 > > 
 > > $ find . -type f | xargs cat | wc -l
 > 
 > You do want to prune the .svn directories and handle names with whitespace in it:
 > 
 > find . -name .svn -prune -o -type f -print0 | xargs -0 cat | wc -l
 > 
 > If you don't mind seeing the line counts for each file and run a little faster:
 > 
 > find . -name .svn -prune -o -type f -print0 | xargs -0 wc -l

You have to be careful interpreting the results of that last one
when you have a large number of files because xargs may invoke
your command more than once due to the system argv size limit
(see sysconf(3)).  Your output may look like:

  938 file1
  . . .
  123 fileN
21232 total    (probably won't see this whiz by...)
  234 fileN+1
  . . .
 3434 fileN+M
34343 total    (...and will think this is the actual total)

-- bart

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Source code lines counter

Posted by Blair Zajac <bl...@orcaware.com>.
Noah Slater wrote:
> Vigo,
> 
> You can run this on *nix based systems:
> 
> $ find . -type f | xargs cat | wc -l

You do want to prune the .svn directories and handle names with whitespace in it:

find . -name .svn -prune -o -type f -print0 | xargs -0 cat | wc -l

If you don't mind seeing the line counts for each file and run a little faster:

find . -name .svn -prune -o -type f -print0 | xargs -0 wc -l

Regards,
Blair

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Source code lines counter

Posted by Noah Slater <ns...@gmail.com>.
Vigo,

You can run this on *nix based systems:

$ find . -type f | xargs cat | wc -l

I hope this helps.

Noah

On 11/08/06, Vigo, Nestor <Ne...@pearson.com> wrote:
> Are there any way to count source code lines that are included under a tag
> in Subversion?
>
> Any help will be greatly apprecited.
>
> Kind regards.
>
> ****************************************************************************
> This email may contain confidential material.
> If you were not an intended recipient,
> Please notify the sender and delete all copies.
> We may monitor email to and from our network.
> ****************************************************************************
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>


-- 
"Creativity can be a social contribution, but only in so
far as society is free to use the results." - R. Stallman

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Source code lines counter

Posted by Ryan Schmidt <su...@ryandesign.com>.
On Aug 11, 2006, at 20:30, Vigo, Nestor wrote:

> Are there any way to count source code lines that are included  
> under a tag
> in Subversion?

There's nothing built into Subversion for that, but with standard  
Unix command-line tools you could do something like this to count the  
lines in all the .php files, say:

svn checkout $REPO/project/trunk
find trunk -type f -name '*.php' -print0 | xargs -0 wc -l


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Source code lines counter

Posted by Simon Roby <si...@gmail.com>.
On 8/11/06, Vigo, Nestor <Ne...@pearson.com> wrote:
> Are there any way to count source code lines that are included under a tag
> in Subversion?
>
> Any help will be greatly apprecited.
>
> Kind regards.

You might want to take a look at SLOCCount
http://www.dwheeler.com/sloccount/
It does smart line counting (ie. it knows about programming language syntaxes)
-- 
- SR

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org