{"id":282,"date":"2007-10-28T14:19:25","date_gmt":"2007-10-28T18:19:25","guid":{"rendered":"http:\/\/michaelnielsen.org\/blog\/?p=282"},"modified":"2007-10-28T14:29:46","modified_gmt":"2007-10-28T18:29:46","slug":"ruby-script-to-count-the-number-of-lines-changed-in-a-subversion-repository","status":"publish","type":"post","link":"https:\/\/michaelnielsen.org\/blog\/ruby-script-to-count-the-number-of-lines-changed-in-a-subversion-repository\/","title":{"rendered":"Ruby script to count the number of lines changed in a subversion repository"},"content":{"rendered":"<p>I like to set minimal targets for the amount of work I&#8217;m going to do on different projects during a week &#8211; things like word counts on papers, and so on.  In that vein, here&#8217;s a short Ruby script to count the number of lines changed in a subversion repository.  It returns the number of added lines and deleted lines from today&#8217;s edits.  The advantage of this over most wordcount facilities is that it can be used both for programming and writing projects, and copes with an entire directory structure, not just a single file.<\/p>\n<p>print &#8220;Additions: &#8221;<\/p>\n<p>puts `svn diff -r \\{#{(Time.now-86400).strftime(&#8216;%Y-%m-%d&#8217;)}\\}:\\{#{<br \/>\n(Time.now+86400).strftime(&#8216;%Y-%m-%d&#8217;)}\\} | grep \\&#8221;^+\\&#8221; | wc`<\/p>\n<p>print &#8220;Deletions: &#8221;<\/p>\n<p>puts `svn diff -r \\{#{(Time.now-86400).strftime(&#8216;%Y-%m-%d&#8217;)}\\}:\\{#{<br \/>\n(Time.now+86400).strftime(&#8216;%Y-%m-%d&#8217;)}\\} | grep \\&#8221;^\\\\-\\&#8221; | wc`<\/p>\n<p>It&#8217;s easily modified to run as a shell script, or to vary the dates.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I like to set minimal targets for the amount of work I&#8217;m going to do on different projects during a week &#8211; things like word counts on papers, and so on. In that vein, here&#8217;s a short Ruby script to count the number of lines changed in a subversion repository. It returns the number of&hellip; <a class=\"more-link\" href=\"https:\/\/michaelnielsen.org\/blog\/ruby-script-to-count-the-number-of-lines-changed-in-a-subversion-repository\/\">Continue reading <span class=\"screen-reader-text\">Ruby script to count the number of lines changed in a subversion repository<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-282","post","type-post","status-publish","format-standard","hentry","entry"],"_links":{"self":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/posts\/282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/comments?post=282"}],"version-history":[{"count":0,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/posts\/282\/revisions"}],"wp:attachment":[{"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/media?parent=282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/categories?post=282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/michaelnielsen.org\/blog\/wp-json\/wp\/v2\/tags?post=282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}