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)

248 lines (246 loc) 9.79 kB
(function (_, childProcess, kotlin_kotlin) { 'use strict'; //region block: imports var imul = Math.imul; var toString = kotlin_kotlin.$_$.e8; var protoOf = kotlin_kotlin.$_$.c8; var getStringHashCode = kotlin_kotlin.$_$.c7; var hashCode = kotlin_kotlin.$_$.d7; var equals = kotlin_kotlin.$_$.y6; var initMetadataForClass = kotlin_kotlin.$_$.e7; var plus = kotlin_kotlin.$_$.e5; var emptyMap = kotlin_kotlin.$_$.d4; var VOID = kotlin_kotlin.$_$.c; var split = kotlin_kotlin.$_$.ha; var ArrayList_init_$Create$ = kotlin_kotlin.$_$.h; var joinToString = kotlin_kotlin.$_$.n4; var reversed = kotlin_kotlin.$_$.k5; var Companion_getInstance = kotlin_kotlin.$_$.q2; var last = kotlin_kotlin.$_$.t4; var Unit_instance = kotlin_kotlin.$_$.z2; var isBlank = kotlin_kotlin.$_$.v9; var collectionSizeOrDefault = kotlin_kotlin.$_$.v3; var ArrayList_init_$Create$_0 = kotlin_kotlin.$_$.g; var charSequenceLength = kotlin_kotlin.$_$.v6; var listOf = kotlin_kotlin.$_$.x4; var THROW_CCE = kotlin_kotlin.$_$.jb; var isCharSequence = kotlin_kotlin.$_$.o7; var trim = kotlin_kotlin.$_$.ua; var emptyList = kotlin_kotlin.$_$.c4; var listOf_0 = kotlin_kotlin.$_$.w4; var plus_0 = kotlin_kotlin.$_$.h5; var first = kotlin_kotlin.$_$.g4; var copyToArray = kotlin_kotlin.$_$.a4; var to = kotlin_kotlin.$_$.hc; var json = kotlin_kotlin.$_$.w7; var Exception_init_$Create$ = kotlin_kotlin.$_$.t; var toList = kotlin_kotlin.$_$.w5; //endregion //region block: pre-declaration initMetadataForClass(CommitRef, 'CommitRef'); initMetadataForClass(GitAdapter, 'GitAdapter'); initMetadataForClass(TagRef, 'TagRef'); //endregion function CommitRef(id, authorEmail, committerEmail, dateTime, parents, fullMessage) { this.sj_1 = id; this.tj_1 = authorEmail; this.uj_1 = committerEmail; this.vj_1 = dateTime; this.wj_1 = parents; this.xj_1 = fullMessage; } protoOf(CommitRef).toString = function () { return 'CommitRef(id=' + this.sj_1 + ', authorEmail=' + this.tj_1 + ', committerEmail=' + this.uj_1 + ', dateTime=' + this.vj_1.toString() + ', parents=' + toString(this.wj_1) + ', fullMessage=' + this.xj_1 + ')'; }; protoOf(CommitRef).hashCode = function () { var result = getStringHashCode(this.sj_1); result = imul(result, 31) + getStringHashCode(this.tj_1) | 0; result = imul(result, 31) + getStringHashCode(this.uj_1) | 0; result = imul(result, 31) + this.vj_1.hashCode() | 0; result = imul(result, 31) + hashCode(this.wj_1) | 0; result = imul(result, 31) + getStringHashCode(this.xj_1) | 0; return result; }; protoOf(CommitRef).equals = function (other) { if (this === other) return true; if (!(other instanceof CommitRef)) return false; if (!(this.sj_1 === other.sj_1)) return false; if (!(this.tj_1 === other.tj_1)) return false; if (!(this.uj_1 === other.uj_1)) return false; if (!this.vj_1.equals(other.vj_1)) return false; if (!equals(this.wj_1, other.wj_1)) return false; if (!(this.xj_1 === other.xj_1)) return false; return true; }; function runProcess($this, args, env) { return runProcess_0(args, $this.yj_1, plus(env, $this.zj_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.o(); while (_iterator__ex2g4s.p()) { var element = _iterator__ex2g4s.q(); var commaSplit = split(element, [',']); var tmp; if (commaSplit.s() >= 3) { tmp = new TagRef(joinToString(commaSplit.t1(0, commaSplit.s() - 2 | 0), ''), reversed(commaSplit).r(1), Companion_getInstance().tg(last(commaSplit))); } else { tmp = null; } var tmp0_safe_receiver = tmp; if (tmp0_safe_receiver == null) null; else { // Inline function 'kotlin.let' call destination.g(tmp0_safe_receiver); } } var output = destination; return output; } function parseLog($this, outputText) { // Inline function 'kotlin.collections.filter' call var tmp0 = split(outputText, [$this.ak_1 + '\n']); // Inline function 'kotlin.collections.filterTo' call var destination = ArrayList_init_$Create$(); var _iterator__ex2g4s = tmp0.o(); while (_iterator__ex2g4s.p()) { var element = _iterator__ex2g4s.q(); // Inline function 'kotlin.text.isNotBlank' call if (!isBlank(element)) { destination.g(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.o(); while (_iterator__ex2g4s_0.p()) { var item = _iterator__ex2g4s_0.q(); var elements = split(item, ['\n']); var tmp = elements.r(0); var tmp_0 = elements.r(1); var tmp_1 = elements.r(2); var tmp_2 = Companion_getInstance().tg(elements.r(3)); // Inline function 'kotlin.collections.filter' call var tmp0_0 = split(elements.r(4), [' ']); // Inline function 'kotlin.collections.filterTo' call var destination_1 = ArrayList_init_$Create$(); var _iterator__ex2g4s_1 = tmp0_0.o(); while (_iterator__ex2g4s_1.p()) { var element_0 = _iterator__ex2g4s_1.q(); // Inline function 'kotlin.text.isNotEmpty' call if (charSequenceLength(element_0) > 0) { destination_1.g(element_0); } } var tmp$ret$8 = new CommitRef(tmp, tmp_0, tmp_1, tmp_2, destination_1, joinToString(elements.t1(5, elements.s()), '\n')); destination_0.g(tmp$ret$8); } return destination_0; } function GitAdapter(workingDirectory, env) { env = env === VOID ? emptyMap() : env; this.yj_1 = workingDirectory; this.zj_1 = env; this.ak_1 = '--------!--------'; this.bk_1 = '%H%n%ae%n%ce%n%aI%n%P%n%B%n' + this.ak_1; } protoOf(GitAdapter).ck = 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).dk = 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).ek = function () { return parseLog(this, runProcess$default(this, listOf(['git', '--no-pager', 'log', '--format=' + this.bk_1]))); }; protoOf(GitAdapter).fk = function (begin, end) { return parseLog(this, runProcess$default(this, plus_0(listOf(['git', '--no-pager', 'log', '--format=' + this.bk_1, begin]), !(end == null) ? listOf_0(end) : emptyList()))); }; protoOf(GitAdapter).gk = function (begin, end, $super) { end = end === VOID ? null : end; return $super === VOID ? this.fk(begin, end) : $super.fk.call(this, begin, end); }; function TagRef(name, commitId, dateTime) { this.hk_1 = name; this.ik_1 = commitId; this.jk_1 = dateTime; } protoOf(TagRef).toString = function () { return 'TagRef(name=' + this.hk_1 + ', commitId=' + this.ik_1 + ', dateTime=' + this.jk_1.toString() + ')'; }; protoOf(TagRef).hashCode = function () { var result = getStringHashCode(this.hk_1); result = imul(result, 31) + getStringHashCode(this.ik_1) | 0; result = imul(result, 31) + this.jk_1.hashCode() | 0; return result; }; protoOf(TagRef).equals = function (other) { if (this === other) return true; if (!(other instanceof TagRef)) return false; if (!(this.hk_1 === other.hk_1)) return false; if (!(this.ik_1 === other.ik_1)) return false; if (!this.jk_1.equals(other.jk_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.t1(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'))); //# sourceMappingURL=tools-git-adapter.js.map