UNPKG

git-digger

Version:

![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/robertfmurdock/ze-great-tools?label=Release) ![NPM Version](https://img.shields.io/npm/v/git-digger?label=npm%20git-digger)

250 lines (248 loc) 10.3 kB
(function (_, childProcess, kotlin_kotlin, kotlin_org_jetbrains_kotlinx_kotlinx_datetime) { 'use strict'; //region block: imports var imul = Math.imul; var toString = kotlin_kotlin.$_$.u8; var protoOf = kotlin_kotlin.$_$.r8; var getStringHashCode = kotlin_kotlin.$_$.q7; var hashCode = kotlin_kotlin.$_$.r7; var THROW_CCE = kotlin_kotlin.$_$.zb; var equals = kotlin_kotlin.$_$.m7; var initMetadataForClass = kotlin_kotlin.$_$.s7; var plus = kotlin_kotlin.$_$.q5; var emptyMap = kotlin_kotlin.$_$.p4; var VOID = kotlin_kotlin.$_$.g; var split = kotlin_kotlin.$_$.xa; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.l; var joinToString = kotlin_kotlin.$_$.z4; var reversed = kotlin_kotlin.$_$.x5; var Companion_getInstance = kotlin_org_jetbrains_kotlinx_kotlinx_datetime.$_$.b; var last = kotlin_kotlin.$_$.f5; var Unit_instance = kotlin_kotlin.$_$.j3; var isBlank = kotlin_kotlin.$_$.ja; var collectionSizeOrDefault = kotlin_kotlin.$_$.g4; var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.k; var charSequenceLength = kotlin_kotlin.$_$.j7; var listOf = kotlin_kotlin.$_$.j5; var isCharSequence = kotlin_kotlin.$_$.c8; var trim = kotlin_kotlin.$_$.jb; var emptyList = kotlin_kotlin.$_$.o4; var listOf_0 = kotlin_kotlin.$_$.i5; var plus_0 = kotlin_kotlin.$_$.t5; var first = kotlin_kotlin.$_$.s4; var copyToArray = kotlin_kotlin.$_$.l4; var to = kotlin_kotlin.$_$.xc; var json = kotlin_kotlin.$_$.k8; var Exception_init_$Create$ = kotlin_kotlin.$_$.z; var toList = kotlin_kotlin.$_$.k6; //endregion //region block: pre-declaration initMetadataForClass(CommitRef, 'CommitRef'); initMetadataForClass(GitAdapter, 'GitAdapter'); initMetadataForClass(TagRef, 'TagRef'); //endregion function CommitRef(id, authorEmail, committerEmail, dateTime, parents, fullMessage) { this.m1b_1 = id; this.n1b_1 = authorEmail; this.o1b_1 = committerEmail; this.p1b_1 = dateTime; this.q1b_1 = parents; this.r1b_1 = fullMessage; } protoOf(CommitRef).toString = function () { return 'CommitRef(id=' + this.m1b_1 + ', authorEmail=' + this.n1b_1 + ', committerEmail=' + this.o1b_1 + ', dateTime=' + this.p1b_1.toString() + ', parents=' + toString(this.q1b_1) + ', fullMessage=' + this.r1b_1 + ')'; }; protoOf(CommitRef).hashCode = function () { var result = getStringHashCode(this.m1b_1); result = imul(result, 31) + getStringHashCode(this.n1b_1) | 0; result = imul(result, 31) + getStringHashCode(this.o1b_1) | 0; result = imul(result, 31) + this.p1b_1.hashCode() | 0; result = imul(result, 31) + hashCode(this.q1b_1) | 0; result = imul(result, 31) + getStringHashCode(this.r1b_1) | 0; return result; }; protoOf(CommitRef).equals = function (other) { if (this === other) return true; if (!(other instanceof CommitRef)) return false; var tmp0_other_with_cast = other instanceof CommitRef ? other : THROW_CCE(); if (!(this.m1b_1 === tmp0_other_with_cast.m1b_1)) return false; if (!(this.n1b_1 === tmp0_other_with_cast.n1b_1)) return false; if (!(this.o1b_1 === tmp0_other_with_cast.o1b_1)) return false; if (!this.p1b_1.equals(tmp0_other_with_cast.p1b_1)) return false; if (!equals(this.q1b_1, tmp0_other_with_cast.q1b_1)) return false; if (!(this.r1b_1 === tmp0_other_with_cast.r1b_1)) return false; return true; }; function runProcess($this, args, env) { return runProcess_0(args, $this.s1b_1, plus(env, $this.t1b_1)); } function runProcess$default($this, args, env, $super) { env = env === VOID ? emptyMap() : env; return runProcess($this, args, env); } function parseTagRefs($this, outputText) { // Inline function 'kotlin.collections.mapNotNull' call var tmp0 = split(outputText, ['\n']); // Inline function 'kotlin.collections.mapNotNullTo' call var destination = ArrayList_init_$Create$(); // Inline function 'kotlin.collections.forEach' call var _iterator__ex2g4s = tmp0.p(); while (_iterator__ex2g4s.q()) { var element = _iterator__ex2g4s.r(); var commaSplit = split(element, [',']); var tmp; if (commaSplit.s() >= 3) { tmp = new TagRef(joinToString(commaSplit.s1(0, commaSplit.s() - 2 | 0), ''), reversed(commaSplit).t(1), Companion_getInstance().p1a(last(commaSplit))); } else { tmp = null; } var tmp0_safe_receiver = tmp; if (tmp0_safe_receiver == null) null; else { // Inline function 'kotlin.let' call destination.e(tmp0_safe_receiver); } } var output = destination; return output; } function parseLog($this, outputText) { // Inline function 'kotlin.collections.filter' call var tmp0 = split(outputText, [$this.u1b_1 + '\n']); // Inline function 'kotlin.collections.filterTo' call var destination = ArrayList_init_$Create$(); var _iterator__ex2g4s = tmp0.p(); while (_iterator__ex2g4s.q()) { var element = _iterator__ex2g4s.r(); // Inline function 'kotlin.text.isNotBlank' call if (!isBlank(element)) { destination.e(element); } } // Inline function 'kotlin.collections.map' call // Inline function 'kotlin.collections.mapTo' call var destination_0 = ArrayList_init_$Create$_0(collectionSizeOrDefault(destination, 10)); var _iterator__ex2g4s_0 = destination.p(); while (_iterator__ex2g4s_0.q()) { var item = _iterator__ex2g4s_0.r(); var elements = split(item, ['\n']); var tmp = elements.t(0); var tmp_0 = elements.t(1); var tmp_1 = elements.t(2); var tmp_2 = Companion_getInstance().p1a(elements.t(3)); // Inline function 'kotlin.collections.filter' call var tmp0_0 = split(elements.t(4), [' ']); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_1 = tmp0_0.p(); while (_iterator__ex2g4s_1.q()) { var element_0 = _iterator__ex2g4s_1.r(); // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(element_0) > 0) { destination_1.e(element_0); } } var tmp$ret$8 = new CommitRef(tmp, tmp_0, tmp_1, tmp_2, destination_1, joinToString(elements.s1(5, elements.s()), '\n')); destination_0.e(tmp$ret$8); } return destination_0; } function GitAdapter(workingDirectory, env) { env = env === VOID ? emptyMap() : env; this.s1b_1 = workingDirectory; this.t1b_1 = env; this.u1b_1 = '--------!--------'; this.v1b_1 = '%H%n%ae%n%ce%n%aI%n%P%n%B%n' + this.u1b_1; } protoOf(GitAdapter).w1b = function () { // Inline function 'kotlin.text.trim' call var this_0 = runProcess$default(this, listOf(['git', '--no-pager', 'rev-parse', 'HEAD'])); return toString(trim(isCharSequence(this_0) ? this_0 : THROW_CCE())); }; protoOf(GitAdapter).x1b = function () { return parseTagRefs(this, runProcess$default(this, listOf(['git', '--no-pager', 'tag', '--list', '--sort=-taggerdate', '--format=%(refname:strip=2),%(*objectname),%(creatordate:iso-strict)']))); }; protoOf(GitAdapter).y1b = function () { return parseLog(this, runProcess$default(this, listOf(['git', '--no-pager', 'log', '--format=' + this.v1b_1]))); }; protoOf(GitAdapter).z1b = function (begin, end) { return parseLog(this, runProcess$default(this, plus_0(listOf(['git', '--no-pager', 'log', '--format=' + this.v1b_1, begin]), !(end == null) ? listOf_0(end) : emptyList()))); }; protoOf(GitAdapter).a1c = function (begin, end, $super) { end = end === VOID ? null : end; return $super === VOID ? this.z1b(begin, end) : $super.z1b.call(this, begin, end); }; function TagRef(name, commitId, dateTime) { this.b1c_1 = name; this.c1c_1 = commitId; this.d1c_1 = dateTime; } protoOf(TagRef).toString = function () { return 'TagRef(name=' + this.b1c_1 + ', commitId=' + this.c1c_1 + ', dateTime=' + this.d1c_1.toString() + ')'; }; protoOf(TagRef).hashCode = function () { var result = getStringHashCode(this.b1c_1); result = imul(result, 31) + getStringHashCode(this.c1c_1) | 0; result = imul(result, 31) + this.d1c_1.hashCode() | 0; return result; }; protoOf(TagRef).equals = function (other) { if (this === other) return true; if (!(other instanceof TagRef)) return false; var tmp0_other_with_cast = other instanceof TagRef ? other : THROW_CCE(); if (!(this.b1c_1 === tmp0_other_with_cast.b1c_1)) return false; if (!(this.c1c_1 === tmp0_other_with_cast.c1c_1)) return false; if (!this.d1c_1.equals(tmp0_other_with_cast.d1c_1)) return false; return true; }; function runProcess_0(args, workingDirectory, env) { var tmp; if (env === VOID) { // Inline function 'kotlin.collections.mapOf' call tmp = emptyMap(); } else { tmp = env; } env = tmp; var program = first(args); // Inline function 'kotlin.collections.toTypedArray' call var this_0 = args.s1(1, args.s()); var tmp$ret$1 = copyToArray(this_0); var spawn = childProcess.spawnSync(program, tmp$ret$1, json([to('cwd', workingDirectory), to('maxBuffer', 10485760), to('env', toJson(env))])); if (spawn.status != 0) { var tmp0_safe_receiver = spawn.stderr; // Inline function 'kotlin.js.unsafeCast' call var tmp$ret$2 = tmp0_safe_receiver == null ? null : tmp0_safe_receiver.toString('utf8'); throw Exception_init_$Create$(tmp$ret$2); } var tmp1_safe_receiver = spawn.stdout; // Inline function 'kotlin.js.unsafeCast' call return tmp1_safe_receiver == null ? null : tmp1_safe_receiver.toString('utf8'); } function toJson(_this__u8e3s4) { // Inline function 'kotlin.collections.toTypedArray' call var this_0 = toList(_this__u8e3s4); var tmp$ret$0 = copyToArray(this_0); return json(tmp$ret$0.slice()); } //region block: exports _.$_$ = _.$_$ || {}; _.$_$.a = GitAdapter; //endregion return _; }(module.exports, require('node:child_process'), require('./kotlin-kotlin-stdlib.js'), require('./Kotlin-DateTime-library-kotlinx-datetime.js'))); //# sourceMappingURL=tools-git-adapter.js.map