From 6df679102dd5930fabb7bbb00412b9848489eed9 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Sun, 3 Mar 2024 13:57:03 +0100 Subject: [PATCH 1/4] Debug git command --- Sources/Version-Control/Utils/ShellClient.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sources/Version-Control/Utils/ShellClient.swift b/Sources/Version-Control/Utils/ShellClient.swift index c9c5cdeb..92eb8476 100644 --- a/Sources/Version-Control/Utils/ShellClient.swift +++ b/Sources/Version-Control/Utils/ShellClient.swift @@ -68,6 +68,11 @@ public class ShellClient { // Convert data to a string if let outputString = String(data: data, encoding: .utf8) { + print([ + "Command: \(args.joined(separator: " "))", + "Output: \(outputString)" + ].joined(separator: "\n")) + return outputString } else { throw CommandError.utf8ConversionFailed From b711e625ca710b2fb8121b907b320b992bcf9066 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Sun, 3 Mar 2024 15:14:20 +0100 Subject: [PATCH 2/4] Fix currentDirectoryPath, fixes #22 --- Sources/Version-Control/Base/Core/GitShell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Version-Control/Base/Core/GitShell.swift b/Sources/Version-Control/Base/Core/GitShell.swift index 73ee3125..b01c5fdb 100644 --- a/Sources/Version-Control/Base/Core/GitShell.swift +++ b/Sources/Version-Control/Base/Core/GitShell.swift @@ -44,7 +44,7 @@ public struct GitShell { let process = Process() process.launchPath = "/usr/bin/env" process.arguments = ["git"] + args - process.currentDirectoryPath = path.relativePath.escapedWhiteSpaces() + process.currentDirectoryPath = path.relativePath let stdoutPipe = Pipe() let stderrPipe = Pipe() From 5d0aab0b85b140c0d2eea0c295529b769bec9a96 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Sun, 3 Mar 2024 15:15:11 +0100 Subject: [PATCH 3/4] remove git debug --- Sources/Version-Control/Utils/ShellClient.swift | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Sources/Version-Control/Utils/ShellClient.swift b/Sources/Version-Control/Utils/ShellClient.swift index 92eb8476..c9c5cdeb 100644 --- a/Sources/Version-Control/Utils/ShellClient.swift +++ b/Sources/Version-Control/Utils/ShellClient.swift @@ -68,11 +68,6 @@ public class ShellClient { // Convert data to a string if let outputString = String(data: data, encoding: .utf8) { - print([ - "Command: \(args.joined(separator: " "))", - "Output: \(outputString)" - ].joined(separator: "\n")) - return outputString } else { throw CommandError.utf8ConversionFailed From 3d15f2774394c8037b659fef4867d51a664e42f9 Mon Sep 17 00:00:00 2001 From: Wesley de Groot Date: Sun, 3 Mar 2024 18:46:58 +0100 Subject: [PATCH 4/4] Fix lowerBound <= upperBound, fixes #24 --- .../Core/Parsers/GitDelimiterParser.swift | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Sources/Version-Control/Base/Core/Parsers/GitDelimiterParser.swift b/Sources/Version-Control/Base/Core/Parsers/GitDelimiterParser.swift index 50e25a58..c7e44707 100644 --- a/Sources/Version-Control/Base/Core/Parsers/GitDelimiterParser.swift +++ b/Sources/Version-Control/Base/Core/Parsers/GitDelimiterParser.swift @@ -83,23 +83,25 @@ struct GitDelimiterParser { // start at 1 to avoid 0 modulo X problem. The first record is guaranteed // to be empty anyway (due to %00 at the start of --format) - for i in 1..<(records.count - 1) { - if i % (keys.count + 1) == 0 { - if records[i] != "\n" { - fatalError("Expected newline") + if records.count > 2 { + for i in 1..<(records.count - 1) { + if i % (keys.count + 1) == 0 { + if records[i] != "\n" { + fatalError("Expected newline") + } + continue } - continue - } - entry = entry ?? [T: String]() - let key = keys[consumed % keys.count] - entry![key] = records[i] - consumed += 1 + entry = entry ?? [T: String]() + let key = keys[consumed % keys.count] + entry![key] = records[i] + consumed += 1 - if consumed % keys.count == 0 { - print(entry!) - entries.append(entry!) - entry = nil + if consumed % keys.count == 0 { + print(entry!) + entries.append(entry!) + entry = nil + } } }