Exit with different status code in case of existing repository#98
Merged
Exit with different status code in case of existing repository#98
Conversation
Reviewer's GuideDistinguish the "repository already exists" scenario by exiting with code 2 instead of 1, so that clients can treat it as a successful no-op rather than an error. Sequence Diagram: tuf-job init Handling of tuf-repo-init.sh for Existing RepositorysequenceDiagram
participant TJI as "tuf-job init"
participant S as "tuf-repo-init.sh"
TJI->>S: Execute tuf-repo-init.sh (repository exists)
S->>S: Check if TUF_REPO_PATH/root.json exists (true)
S->>S: Output "Repo seems to already be initialized"
alt Before PR Change
S-->>TJI: Exit code 1
TJI->>TJI: Treats as Error
else After PR Change
S-->>TJI: Exit code 2
TJI->>TJI: Treats as Success (no-op)
end
Flow Diagram: Updated Exit Logic in tuf-repo-init.sh for Existing Repositoryflowchart TD
A[Execution of tuf-repo-init.sh] --> B{Is TUF_REPO_PATH/root.json present?};
B -- Yes --> C["echo 'Repo seems to already be initialized'"];
C --> D{Determine Exit Code};
D -- "Logic Before PR" --> Exit1["exit 1"];
D -- "Logic After PR (Changed)" --> Exit2["exit 2"];
B -- No --> E["Proceed with normal repository initialization"];
E --> F["..."];
style Exit2 fill:#c9ffc9,stroke:#333,stroke-width:2px;
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @bouskaJ - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…isting repository Signed-off-by: Jan Bouska <jbouska@redhat.com>
6e8f86d to
028d5ec
Compare
osmman
approved these changes
Jun 3, 2025
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.
A 'repository already exists' state doesn't necessarily mean an error. Using a distinct exit code for this scenario allows the tuf-job init to correctly signal success when no update is needed for an existing repository, while still ensuring it fails appropriately for misconfigurations.
Summary by Sourcery
Enhancements: