diff --git a/scripts/colors.sh b/scripts/colors.sh deleted file mode 100755 index cf1a6ba..0000000 --- a/scripts/colors.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/bash - -# Extracted command line colors for nicer output - -# Text Reset -RCol='\033[0m' - -# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds -Bla='\033[0;30m'; BBla='\033[1;30m'; UBla='\033[4;30m'; IBla='\033[0;90m'; BIBla='\033[1;90m'; On_Bla='\033[40m'; On_IBla='\033[0;100m'; -Red='\033[0;31m'; BRed='\033[1;31m'; URed='\033[4;31m'; IRed='\033[0;91m'; BIRed='\033[1;91m'; On_Red='\033[41m'; On_IRed='\033[0;101m'; -Gre='\033[0;32m'; BGre='\033[1;32m'; UGre='\033[4;32m'; IGre='\033[0;92m'; BIGre='\033[1;92m'; On_Gre='\033[42m'; On_IGre='\033[0;102m'; -Yel='\033[0;33m'; BYel='\033[1;33m'; UYel='\033[4;33m'; IYel='\033[0;93m'; BIYel='\033[1;93m'; On_Yel='\033[43m'; On_IYel='\033[0;103m'; -Blu='\033[0;34m'; BBlu='\033[1;34m'; UBlu='\033[4;34m'; IBlu='\033[0;94m'; BIBlu='\033[1;94m'; On_Blu='\033[44m'; On_IBlu='\033[0;104m'; -Pur='\033[0;35m'; BPur='\033[1;35m'; UPur='\033[4;35m'; IPur='\033[0;95m'; BIPur='\033[1;95m'; On_Pur='\033[45m'; On_IPur='\033[0;105m'; -Cya='\033[0;36m'; BCya='\033[1;36m'; UCya='\033[4;36m'; ICya='\033[0;96m'; BICya='\033[1;96m'; On_Cya='\033[46m'; On_ICya='\033[0;106m'; -Whi='\033[0;37m'; BWhi='\033[1;37m'; UWhi='\033[4;37m'; IWhi='\033[0;97m'; BIWhi='\033[1;97m'; On_Whi='\033[47m'; On_IWhi='\033[0;107m'; diff --git a/scripts/gitlogg-generate-log.sh b/scripts/gitlogg-generate-log.sh index f6968d9..caf80ba 100755 --- a/scripts/gitlogg-generate-log.sh +++ b/scripts/gitlogg-generate-log.sh @@ -72,24 +72,18 @@ if [ -d "${yourpathSanitized}" ] && [ "$(ls $yourpathSanitized)" ]; then (cd $dir && echo -e " ${Whi}Outputting ${Pur}${PWD##*/}${RCol}" >&2 && git log --all --no-merges --shortstat --reverse --pretty=format:'commits\trepository\t'"${PWD##*/}"'\tcommit_hash\t%H\tcommit_hash_abbreviated\t%h\ttree_hash\t%T\ttree_hash_abbreviated\t%t\tparent_hashes\t%P\tparent_hashes_abbreviated\t%p\tauthor_name\t%an\tauthor_name_mailmap\t%aN\tauthor_email\t%ae\tauthor_email_mailmap\t%aE\tauthor_date\t%ad\tauthor_date_RFC2822\t%aD\tauthor_date_relative\t%ar\tauthor_date_unix_timestamp\t%at\tauthor_date_iso_8601\t%ai\tauthor_date_iso_8601_strict\t%aI\tcommitter_name\t%cn\tcommitter_name_mailmap\t%cN\tcommitter_email\t%ce\tcommitter_email_mailmap\t%cE\tcommitter_date\t%cd\tcommitter_date_RFC2822\t%cD\tcommitter_date_relative\t%cr\tcommitter_date_unix_timestamp\t%ct\tcommitter_date_iso_8601\t%ci\tcommitter_date_iso_8601_strict\t%cI\tref_names\t%d\tref_names_no_wrapping\t%D\tencoding\t%e\tsubject\t%s\tsubject_sanitized\t%f\tcommit_notes\t%N\tstats\t' | - iconv -f ISO-8859-1 -t UTF-8 | # convert ISO-8859-1 encoding to UTF-8 - sed '/^[ \t]*$/d' | # remove all newlines/line-breaks, including those with empty spaces - tr '\n' 'ȝ' | # convert newlines/line-breaks to a character, so we can manipulate it without much trouble - tr '\r' ' ' | # replace carriage returns with a space, so we avoid new lines popping from placeholders that allow user input - sed 's/tȝcommits/tȝȝcommits/g' | # because some commits have no stats, we have to create an extra line-break to make `paste -d ' ' - -` consistent - tr 'ȝ' '\n' | # bring back all line-breaks - sed '{ - N - s/[)]\n\ncommits/)\ - commits/g - }' | # some rogue mystical line-breaks need to go down to their knees and beg for mercy, which they're not getting - paste -d ' ' - - | # collapse lines so that the `shortstat` is merged with the rest of the commit data, on a single line - awk '{print NR"\\t",$0}' | # print line number in front of each line, along with the `\t` delimiter - sed 's/\\t\ commits\\trepo/\\t\commits\\trepo/g' # get rid of the one space that shouldn't be there + iconv -f ISO-8859-1 -t UTF-8 | # convert ISO-8859-1 encoding to UTF-8 + sed ':a;N;$!ba;s/\ncommits/\n\ncommits/g' | # because some commits have no stats, we have to create an extra line-break for consistancy + tr '\r' ' ' | # replace carriage returns with a space, so we avoid new lines popping from placeholders that allow user input + paste -d ' ' - - | # collapse lines so that the `shortstat` is merged with the rest of the commit data, on a single line + sed ':a;N;$!ba;s/tstats\\t\n//g'| # + sed '/^[ \t]*$/d' | # remove all newlines/line-breaks, including those with empty spaces + awk '{print NR"\\t",$0}' | # print line number in front of each line, along with the `\t` delimiter + sed 's/\\t\ commits\\trepo/\\t\commits\\trepo/g' # get rid of the one space that shouldn't be there ) done > "${tempOutputFile}" echo -e "\n ${Gre}The file ${Blu}${tempOutputFile} ${Gre}generated in${RCol}: ${SECONDS}s" && - babel "${jsonParser}" | node # only parse JSON if we have a source to parse it from + babel "${jsonParser}" | node # only parse JSON if we have a source to parse it from # if the path exists but is empty elif [ -d "${yourpathSanitized}" ] && [ ! "$(ls $yourpathSanitized)" ]; then echo -e "\n ${Whi}[ERROR 002]: ${Yel}The path to the local repositories ${Red}'${yourpath}'${Yel}, which is set on the file ${Blu}'${thisFile}' ${UYel}exists, but is empty!${RCol}" diff --git a/scripts/gitlogg-parse-json.js b/scripts/gitlogg-parse-json.js deleted file mode 100644 index 26216df..0000000 --- a/scripts/gitlogg-parse-json.js +++ /dev/null @@ -1,203 +0,0 @@ -var fs = require('fs'), - path = require('path'), - chalk = require('chalk'), - byline = require('byline'), - Transform = require('stream').Transform, - JSONStream = require('JSONStream'), - output_file_temp = '_tmp/gitlogg.tmp', - output_file = '_output/gitlogg.json'; - -console.log(chalk.yellow('\n Parsing JSON output...\n')); - -// initialise timer -console.time(chalk.green(' JSON output parsed in')); - -// create the streams -var stream = fs.createReadStream(output_file_temp, 'utf8'); -var output = fs.createWriteStream(output_file, 'utf8'); -// handle errors -stream.on('error', function() { - console.log(chalk.red(' Could not read from ' + output_file_temp)); -}); -output.on('error', function() { - console.log(chalk.red(' Something went wrong, ' + output_file + ' could not be written / saved')); -}); -// handle completion callback -output.on('finish', function() { - console.timeEnd(chalk.green(' JSON output parsed in')); - console.log(chalk.green(' The file ' + chalk.blue(output_file) + ' was saved. ' + chalk.yellow('Done! ✨\n'))); -}); - -// stream the stream line by line -stream = byline.createStream(stream); -// create a transform stream -var parser = new Transform({ objectMode: true }); -// use a JSONStream: JSONStream.stringify(open, sep, close) -var jsonToStrings = JSONStream.stringify('[\n ', ',\n ','\n]\n'); - -// massage the stats -var changes = function(data, index) { - var v = data.split(',')[index] || 0; - var w = 0; - if (v !== 0) { - var w = v.split(' ')[1]; // the number of changes is second on the array - } - return parseInt(w); -}; - -// decode UTF-8-ized Latin-1/ISO-8859-1 to UTF-8 -var decode = function(str) { - var s; - try { - // if the string is UTF-8, this will work and not throw an error. - s = decodeURIComponent(escape(str)); - } catch(e) { - // if it isn't, an error will be thrown, and we can asume that we have an ISO string. - s = str; - } - return s; -}; - -// replace double quotes with single ones -var unquote = function(str) { - if (str === undefined) { - return ''; - } else if (str != '') { - return str.replace(/"/g, "'"); - } else { - return str; - } -}; - -// slice the string as long as it's not empty -var sliceit = function(str) { - if (str === undefined) { - return ''; - } else if (str != '') { - return str.slice(1); - } else { - return str; - } -} - -// do the transformations, through the transform stream -parser._transform = function(data, encoding, done) { - var separator = /\\t/; - var dataDecoded = decode(data); - var c = dataDecoded.trim().split(separator); - // console.log(c); - // vars based on sequential values ( sanitise " to ' on fields that accept user input ) - var repository = c[3], // color-consolidator - commit_nr = parseInt(c[0], 10), // 3 - commit_hash = c[5], // 5109ad5a394a4873290ff7f7a38b7ca2e1b3b8e1 - commit_hash_abbreviated = c[7], // 5109ad5 - tree_hash = c[9], // a1606ea8d6e24e1c832b52cb9c04ae1df2242ed4 - tree_hash_abbreviated = c[11], // a1606ea - parent_hashes = c[13], // 7082fa621bf93503fe173d06ada3c6111054a62b - parent_hashes_abbreviated = c[15], // 7082fa6 - author_name = unquote(c[17]), // Wallace Sidhrée - author_name_mailmap = unquote(c[19]), // Wallace Sidhrée - author_email = c[21], // i@dreamyguy.com - author_email_mailmap = c[23], // i@dreamyguy.com - author_date = c[25], // Fri Jan 3 14:16:56 2014 +0100 - author_date_RFC2822 = c[27], // Fri, 3 Jan 2014 14:16:56 +0100 - author_date_relative = c[29], // 2 years, 5 months ago - author_date_unix_timestamp = c[31], // 1388755016 - author_date_iso_8601 = c[33], // 2014-01-03 14:16:56 +0100 - author_date_iso_8601_strict = c[35], // 2014-01-03T14:16:56+01:00 - committer_name = unquote(c[37]), // Wallace Sidhrée - committer_name_mailmap = unquote(c[39]), // Wallace Sidhrée - committer_email = c[41], // i@dreamyguy.com - committer_email_mailmap = c[43], // i@dreamyguy.com - committer_date = c[45], // Fri Jan 3 14:16:56 2014 +0100 - committer_date_RFC2822 = c[47], // Fri, 3 Jan 2014 14:16:56 +0100 - committer_date_relative = c[49], // 2 years, 5 months ago - committer_date_unix_timestamp = c[51], // 1388755016 - committer_date_iso_8601 = c[53], // 2014-01-03 14:16:56 +0100 - committer_date_iso_8601_strict = c[55], // 2014-01-03T14:16:56+01:00 - ref_names = unquote(c[57]), // "" - ref_names_no_wrapping = unquote(c[59]), // "" - encoding = c[61], // "" - subject = unquote(c[63]), // Upgrade FontAwesome from 3.2.1 to 4.0.3" - subject_sanitized = c[65], // Upgrade-FontAwesome-from-3.2.1-to-4.0.3" - commit_notes = unquote(c[67]), // "" - stats = sliceit(c[69]); // ` 9 files changed, 507 insertions(+), 2102 deletions(-)` - // vars that require manipulation - var time_array = author_date.split(' '), // Fri Jan 3 14:16:56 2014 +0100 => [Fri, Jan, 3, 14:16:56, 2014, +0100] - time_array_clock = time_array[3].split(':'), // 14:16:56 => [14, 16, 56] - time_hour = parseInt(time_array_clock[0], 10), // [14, 16, 56] => 14 - time_minutes = parseInt(time_array_clock[1], 10), // [14, 16, 56] => 16 - time_seconds = parseInt(time_array_clock[2], 10), // [14, 16, 56] => 56 - time_gmt = time_array[5], // [Fri, Jan, 3, 14:16:56, 2014, +0100] => +0100 - date_array = author_date_iso_8601.split(' ')[0], // 2014-01-03 14:16:56 +0100 => 2014-01-03 - date_day_week = time_array[0], // [Fri, Jan, 3, 14:16:56, 2014, +0100] => Fri - date_iso_8601 = date_array, // 2014-01-03 - date_month_day = parseInt(date_array.split('-')[2], 10), // 2014-01-03 => [2014, 01, 03] => 03 - date_month_name = time_array[1], // [Fri, Jan, 3, 14:16:56, 2014, +0100] => Jan - date_month_number = parseInt(date_array.split('-')[1], 10), // 2014-01-03 => [2014, 01, 03] => 01 - date_year = time_array[4], // [Fri, Jan, 3, 14:16:56, 2014, +0100] => 2014 - files_changed = changes(stats, 0), // ` 9 files changed, 507 insertions(+), 2102 deletions(-)` => 9 - insertions = changes(stats, 1), // ` 9 files changed, 507 insertions(+), 2102 deletions(-)` => 507 - deletions = changes(stats, 2), // ` 9 files changed, 507 insertions(+), 2102 deletions(-)` => 2102 - impact = (insertions - deletions); // 507 - 2102 => -1595 - // create the object - var obj = { - repository: repository, - commit_nr: commit_nr, - commit_hash: commit_hash, - // commit_hash_abbreviated: commit_hash_abbreviated, - // tree_hash: tree_hash, - // tree_hash_abbreviated: tree_hash_abbreviated, - // parent_hashes: parent_hashes, - // parent_hashes_abbreviated: parent_hashes_abbreviated, - author_name: author_name, - // author_name_mailmap: author_name_mailmap, - author_email: author_email, - // author_email_mailmap: author_email_mailmap, - author_date: author_date, - // author_date_RFC2822: author_date_RFC2822, - author_date_relative: author_date_relative, - author_date_unix_timestamp: author_date_unix_timestamp, - author_date_iso_8601: author_date_iso_8601, - // author_date_iso_8601_strict: author_date_iso_8601_strict, - // committer_name: committer_name, - // committer_name_mailmap: committer_name_mailmap, - // committer_email: committer_email, - // committer_email_mailmap: committer_email_mailmap, - // committer_date: committer_date, - // committer_date_RFC2822: committer_date_RFC2822, - // committer_date_relative: committer_date_relative, - // committer_date_unix_timestamp: committer_date_unix_timestamp, - // committer_date_iso_8601: committer_date_iso_8601, - // committer_date_iso_8601_strict: committer_date_iso_8601_strict, - // ref_names: ref_names, - // ref_names_no_wrapping: ref_names_no_wrapping, - // encoding: encoding, - subject: subject, - subject_sanitized: subject_sanitized, - // commit_notes: commit_notes, - stats: stats, - time_hour: time_hour, - time_minutes: time_minutes, - time_seconds: time_seconds, - time_gmt: time_gmt, - date_day_week: date_day_week, - date_month_day: date_month_day, - date_month_name: date_month_name, - date_month_number: date_month_number, - date_year: date_year, - date_iso_8601: date_iso_8601, - files_changed: files_changed, - insertions: insertions, - deletions: deletions, - impact: impact - }; - this.push(obj); - done(); -}; - -// initialise stream -stream -.pipe(parser) -.pipe(jsonToStrings) -.pipe(output); diff --git a/scripts/gitlogg.sh b/scripts/gitlogg.sh deleted file mode 100755 index 1bf529d..0000000 --- a/scripts/gitlogg.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -bash ./scripts/gitlogg-generate-log.sh