From d7ec9aec9de7bd21db24d14bec1acae3c650f7f3 Mon Sep 17 00:00:00 2001 From: "Premkumar, Prasad (pp2805)" Date: Sun, 11 Aug 2019 15:50:03 +0530 Subject: [PATCH] Issue#21: Exposed git hook input params as shell env vars GIT_PARAMS --- Package.resolved | 9 --------- Sources/Komondor/Commands/runner.swift | 5 ++++- Sources/Komondor/Installation/renderScript.swift | 2 +- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Package.resolved b/Package.resolved index 4e4150c..d49e82e 100644 --- a/Package.resolved +++ b/Package.resolved @@ -126,15 +126,6 @@ "revision": "f43166a8e18fdd0857f29e303b1bb79a5428bca0", "version": "4.9.0" } - }, - { - "package": "Yams", - "repositoryURL": "https://github.com/jpsim/Yams.git", - "state": { - "branch": null, - "revision": "b08dba4bcea978bf1ad37703a384097d3efce5af", - "version": "1.0.2" - } } ] }, diff --git a/Sources/Komondor/Commands/runner.swift b/Sources/Komondor/Commands/runner.swift index 7822728..ce7f093 100644 --- a/Sources/Komondor/Commands/runner.swift +++ b/Sources/Komondor/Commands/runner.swift @@ -37,8 +37,11 @@ public func runner(logger _: Logger, args: [String]) throws { do { try commands.forEach { command in print("> \(command)") + let gitParams = Array(args.dropFirst()) + // Exporting git hook input params as shell env var GIT_PARAMS + let cmd = "export GIT_PARAMS=\(gitParams.joined(separator: " ")) ; \(command)" // Simple is fine for now - print(try shellOut(to: command)) + print(try shellOut(to: cmd)) // Ideal: // Store STDOUT and STDERR, and only show it if it fails // Show a stepper like system of all commands diff --git a/Sources/Komondor/Installation/renderScript.swift b/Sources/Komondor/Installation/renderScript.swift index 35d5db6..931c002 100644 --- a/Sources/Komondor/Installation/renderScript.swift +++ b/Sources/Komondor/Installation/renderScript.swift @@ -22,7 +22,7 @@ public func renderScript(_ hookName: String, _ swiftPackagePath: String) -> Stri komondor=${komondor:-'swift run komondor'} # run hook - $komondor run \(hookName) + $komondor run \(hookName) $gitParams fi """ }