77
88import Foundation
99import GitShellKit
10- import NnShellKit
1110
12- /// Default implementation of the GitHandler protocol, providing Git-related operations.
1311public struct DefaultGitHandler {
14- private let shell : any Shell
15- private let gitShell : any GitShell
12+ private let shell : any NnexShell
1613
17- /// Initializes a new instance of DefaultGitHandler with the specified shell.
18- /// - Parameter shell: The shell used to execute commands.
19- public init ( shell: any Shell ) {
14+ public init ( shell: any NnexShell ) {
2015 self . shell = shell
21- self . gitShell = GitShellAdapter ( shell: shell)
2216 }
2317}
2418
@@ -30,16 +24,16 @@ extension DefaultGitHandler: GitHandler {
3024 /// - message: The commit message describing the changes.
3125 /// - path: The file path of the repository.
3226 public func commitAndPush( message: String , path: String ) throws {
33- _ = try shell. bash ( makeGitCommand ( . addAll, path: path) )
34- _ = try shell. bash ( makeGitCommand ( . commit( message: message) , path: path) )
35- _ = try shell. bash ( makeGitCommand ( . push, path: path) )
27+ try shell. runAndPrint ( bash : makeGitCommand ( . addAll, path: path) )
28+ try shell. runAndPrint ( bash : makeGitCommand ( . commit( message: message) , path: path) )
29+ try shell. runAndPrint ( bash : makeGitCommand ( . push, path: path) )
3630 }
3731
3832 /// Retrieves the remote URL of the repository located at the given path.
3933 /// - Parameter path: The file path of the repository.
4034 /// - Returns: A string representing the remote URL.
4135 public func getRemoteURL( path: String ) throws -> String {
42- return try gitShell . getGitHubURL ( at: path)
36+ return try shell . getGitHubURL ( at: path)
4337 }
4438
4539 /// Retrieves the previous release version from the repository at the given path.
@@ -52,7 +46,7 @@ extension DefaultGitHandler: GitHandler {
5246 /// Initializes a new Git repository at the given path.
5347 /// - Parameter path: The file path where the repository should be initialized.
5448 public func gitInit( path: String ) throws {
55- try GitStarter ( path: path, shell: gitShell ) . gitInit ( )
49+ try GitStarter ( path: path, shell: shell ) . gitInit ( )
5650 }
5751
5852 /// Initializes a new remote repository on GitHub with specified details and returns the repository URL.
@@ -64,7 +58,7 @@ extension DefaultGitHandler: GitHandler {
6458 /// - Returns: A string representing the repository URL.
6559 public func remoteRepoInit( tapName: String , path: String , projectDetails: String , visibility: RepoVisibility ) throws -> String {
6660 let info = RepoInfo ( name: tapName, details: projectDetails, visibility: visibility, canUploadFromNonMainBranch: false )
67- return try GitHubRepoStarter ( path: path, shell: gitShell , repoInfo: info) . repoInit ( )
61+ return try GitHubRepoStarter ( path: path, shell: shell , repoInfo: info) . repoInit ( )
6862 }
6963
7064 /// Creates a new release with one or more archived binaries and returns all asset URLs.
@@ -102,7 +96,7 @@ private extension DefaultGitHandler {
10296 // Create the release and upload all archives at once
10397 let quotedArchivePaths = archivedBinaries. map { " \" \( $0. archivePath) \" " } . joined ( separator: " " )
10498 let createCmd = " cd \" \( path) \" && gh release create \( version) \( quotedArchivePaths) --title \" \( version) \" \( notesParam) "
105- _ = try shell. bash ( createCmd)
99+ try shell. runAndPrint ( bash : createCmd)
106100
107101 // Clean up archive files after upload
108102 let archiver = BinaryArchiver ( shell: shell)
0 commit comments