Manage Runtime Automatically - #11
Merged
Merged
Conversation
- Added runtime initialization and shutdown logic in ConfigCollection methods to ensure proper management of the SwiftGitXRuntime. - Updated Repository initialization and cloning methods to include runtime management, ensuring the runtime is initialized before operations and shut down afterward. - Removed runtime initialization from the SwiftGitXTest class constructor and deinitializer, as it is no longer necessary.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements automatic runtime management for the SwiftGitX library by embedding SwiftGitXRuntime.initialize() and shutdown() calls at public entry points, eliminating the need for developers to manually manage the libgit2 runtime lifecycle.
Key Changes:
- Removed manual runtime initialization/shutdown from test infrastructure
- Added automatic initialization to all
Repositorycreation paths (init, open, create, clone) - Implemented conditional runtime management for
ConfigCollectionwhen accessing global config without a repository context
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| Tests/SwiftGitXTests/SwiftGitXTests.swift | Removed manual init/shutdown calls from test base class |
| Sources/SwiftGitX/Repository/Repository.swift | Added runtime initialization to public initializer and static factory methods (open, create) with shutdown on error paths |
| Sources/SwiftGitX/Repository/Repository+clone.swift | Added runtime initialization to clone methods with shutdown on error paths |
| Sources/SwiftGitX/Collections/ConfigCollection.swift | Added conditional runtime management for global config operations; fixed missing return statement in configPointer() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds automatic runtime management by adding initialization and shutdown methods to public static entrypoints.
The developers don't need to call runtime init, shutdown manually from now on.