From 0fe74d35ee31ac3fb38fe647786b0b71629d64d0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Sun, 26 Mar 2017 21:25:04 -0700 Subject: Initial historical line counter --- tools/line_count/collect-history.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 tools/line_count/collect-history.py (limited to 'tools/line_count/collect-history.py') diff --git a/tools/line_count/collect-history.py b/tools/line_count/collect-history.py new file mode 100755 index 0000000000..0de95f2bac --- /dev/null +++ b/tools/line_count/collect-history.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +import subprocess +import datetime + +def daterange(start, end): + for n in range(int((end - start).days)): + yield start + datetime.timedelta(n) + +start_date = datetime.date(2014, 11, 21) +end_date = datetime.date(2017, 3, 26) + +for dt in daterange(start_date, end_date): + dmy = dt.strftime('%Y-%m-%d') + sha1 = subprocess.check_output(['git', 'rev-list', '-n', '1', + '--before=%s' % dmy, + 'master']).strip() + subprocess.check_call(['git', 'checkout', sha1]) + subprocess.check_call(['git', 'submodule', 'update']) + subprocess.check_call(['git', 'clean', '-f', '-x', '-d']) + subprocess.check_call(['cloc', '--vcs=git', '--by-file', '--yaml', '--out=../count/%s.yaml' % dmy, '.']) + -- cgit v1.2.3 From 0fc13f9d807f6db35ace60c8f6ec6ad093765bca Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Mar 2017 14:38:10 -0700 Subject: Backfill --- tools/line_count/collect-history.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/line_count/collect-history.py') diff --git a/tools/line_count/collect-history.py b/tools/line_count/collect-history.py index 0de95f2bac..e5e8b42fdc 100755 --- a/tools/line_count/collect-history.py +++ b/tools/line_count/collect-history.py @@ -7,8 +7,8 @@ def daterange(start, end): for n in range(int((end - start).days)): yield start + datetime.timedelta(n) -start_date = datetime.date(2014, 11, 21) -end_date = datetime.date(2017, 3, 26) +start_date = datetime.date(2017, 3, 26) +end_date = datetime.date(2017, 3, 29) for dt in daterange(start_date, end_date): dmy = dt.strftime('%Y-%m-%d') -- cgit v1.2.3 From 45f96aa3a7bcc36626c6cea7be12c9348aad42f4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Mar 2017 14:44:51 -0700 Subject: Fix copyright --- tools/line_count/collect-history.py | 28 ++++++++++++++++++++++++++++ tools/line_count/summarize-history.py | 29 +++++++++++++++++++++++++++++ tools/line_count/yaml2csv.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) (limited to 'tools/line_count/collect-history.py') diff --git a/tools/line_count/collect-history.py b/tools/line_count/collect-history.py index e5e8b42fdc..858a6e1d30 100755 --- a/tools/line_count/collect-history.py +++ b/tools/line_count/collect-history.py @@ -1,4 +1,32 @@ #!/usr/bin/env python +# Copyright 2017, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import subprocess import datetime diff --git a/tools/line_count/summarize-history.py b/tools/line_count/summarize-history.py index af87ddb31a..756dc79a4d 100755 --- a/tools/line_count/summarize-history.py +++ b/tools/line_count/summarize-history.py @@ -1,4 +1,33 @@ #!/usr/bin/env python +# Copyright 2017, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + import subprocess import datetime diff --git a/tools/line_count/yaml2csv.py b/tools/line_count/yaml2csv.py index 159901ac41..9bda09fd08 100755 --- a/tools/line_count/yaml2csv.py +++ b/tools/line_count/yaml2csv.py @@ -1,4 +1,33 @@ #!/usr/bin/env python +# Copyright 2017, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + import yaml import argparse -- cgit v1.2.3 From 240b20da06e717ffdb921330093d5c8cef9a0f21 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 Mar 2017 14:46:34 -0700 Subject: Review feedback --- tools/line_count/collect-history.py | 3 +++ tools/line_count/collect-now.sh | 2 +- tools/line_count/summarize-history.py | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'tools/line_count/collect-history.py') diff --git a/tools/line_count/collect-history.py b/tools/line_count/collect-history.py index 858a6e1d30..4c1bf73b1e 100755 --- a/tools/line_count/collect-history.py +++ b/tools/line_count/collect-history.py @@ -31,6 +31,9 @@ import subprocess import datetime +# this script is only of historical interest: it's the script that was used to +# bootstrap the dataset + def daterange(start, end): for n in range(int((end - start).days)): yield start + datetime.timedelta(n) diff --git a/tools/line_count/collect-now.sh b/tools/line_count/collect-now.sh index 2db26298dc..44f4b4ed31 100644 --- a/tools/line_count/collect-now.sh +++ b/tools/line_count/collect-now.sh @@ -31,6 +31,6 @@ set -ex cloc --vcs=git --by-file --yaml --out=cloc.yaml . -tools/line_count/yaml2csv -i cloc.yaml -d `date +%Y-%m-%d` -o cloc.csv +tools/line_count/yaml2csv.py -i cloc.yaml -d `date +%Y-%m-%d` -o cloc.csv bq load line_counts.grpc cloc.csv diff --git a/tools/line_count/summarize-history.py b/tools/line_count/summarize-history.py index 756dc79a4d..cb6d570f66 100755 --- a/tools/line_count/summarize-history.py +++ b/tools/line_count/summarize-history.py @@ -32,6 +32,9 @@ import subprocess import datetime +# this script is only of historical interest: it's the script that was used to +# bootstrap the dataset + def daterange(start, end): for n in range(int((end - start).days)): yield start + datetime.timedelta(n) -- cgit v1.2.3