Skip to content

Conversation

@bicschneider
Copy link
Collaborator

@bicschneider bicschneider commented Aug 1, 2025

additionally: refactor tests to functions and enable single test case execution

Summary by CodeRabbit

  • New Features
    • Introduced new commands for artifact management: list, summary, and prune, allowing users to view, group, and clean up tags with flexible options.
    • Enhanced test framework with modular test cases, dynamic discovery, and command-line options for debug, verbose, and targeted test execution.
  • Improvements
    • Added detailed help and usage instructions for easier script and tool usage.
    • Improved error handling and user feedback during test and artifact operations.

@coderabbitai
Copy link

coderabbitai bot commented Aug 1, 2025

Walkthrough

The _tests.sh script was refactored for better structure and extensibility, introducing modular test case functions, dynamic discovery and execution, and improved command-line options. The git-artifact tool gained new commands (list, summary, prune) for tag management, updated option parsing, and enhanced help text, with changes to command dispatch and tag filtering logic.

Changes

Cohort / File(s) Change Summary
Test Framework Refactor
_tests.sh
Refactored test script: added modular test case functions, dynamic test discovery and execution, new command-line options (--debug, --verbose, --testcase), improved help/usage, and enhanced error handling. Introduced helper functions (usage, generate_git_test_log). Main logic now invokes test functions by pattern or specific argument. Debug mode setup moved after sourcing dependencies. Test directories and reference logs auto-created if missing.
git-artifact Tag Management Features
git-artifact
Added new commands: list (list tags by glob), summary (aggregate tag counts by prefix), and prune (delete old tags, keep N most recent, supports dry-run and verbose). Updated option parsing to include --glob, --keep, --dryrun, --verbose, and --delimiter. Changed tag filtering from regex to glob. Updated help text and command dispatch logic. Added helper function for reading remote tags. Adjusted debug/quiet flag handling. Modified find-latest to use glob patterns.

Sequence Diagram(s)

git-artifact: Prune Command Flow

sequenceDiagram
    participant User
    participant git-artifact
    participant GitRepo

    User->>git-artifact: Run 'git-artifact prune --glob PATTERN --keep N'
    git-artifact->>GitRepo: List tags matching glob PATTERN
    GitRepo-->>git-artifact: Return tag list
    git-artifact->>git-artifact: Determine tags to delete (all but N most recent)
    alt dry-run
        git-artifact->>User: Print tags that would be deleted
    else actual prune
        git-artifact->>GitRepo: Delete old tags from remote
        git-artifact->>User: Print summary of deleted tags
    end
Loading

_tests.sh: Dynamic Test Execution

sequenceDiagram
    participant User
    participant _tests.sh
    participant TestCaseFn

    User->>_tests.sh: Run script (with or without --testcase)
    _tests.sh->>_tests.sh: Parse options, discover test functions
    alt --testcase specified
        _tests.sh->>TestCaseFn: Invoke specified test function
    else
        loop For each test function
            _tests.sh->>TestCaseFn: Invoke test function
        end
    end
    TestCaseFn->>_tests.sh: Run test, output results, call eval_testcase
    _tests.sh->>User: Print test results and logs
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

In the warren of code, new features abound,
Tests hop as functions, neat and sound.
Artifacts pruned, tags listed with flair,
Rabbits rejoice—less clutter to bear!
With options galore and logic anew,
This patch brings a garden for coders to chew.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66ffb5c and 3bcc012.

⛔ Files ignored due to path filters (3)
  • .test/7/git-reference.log is excluded by !**/*.log
  • .test/8/git-reference.log is excluded by !**/*.log
  • .test/9/git-reference.log is excluded by !**/*.log
📒 Files selected for processing (2)
  • _tests.sh (5 hunks)
  • git-artifact (9 hunks)
🔇 Additional comments (14)
git-artifact (8)

79-115: LGTM! Well-documented new commands and options.

The help text additions for the new list, summary, and prune commands are well-structured and follow the existing documentation pattern. The new options are clearly described with appropriate context.


344-374: LGTM! Well-implemented prune functionality with good error handling.

The cmd_prune function properly:

  • Uses mapfile for safe array population
  • Handles empty tag lists with xargs --no-run-if-empty
  • Implements dry-run and verbose modes
  • Provides clear feedback on tag counts

The implementation addresses potential shell scripting pitfalls effectively.


376-381: LGTM! Clean and efficient list implementation.

The cmd_list function is well-implemented with appropriate quiet mode handling and informative output formatting.


383-406: LGTM! Summary functionality with consistent delimiter usage.

The cmd_summary and read_remote_tags_to_map functions are well-implemented:

  • Proper use of associative arrays for tag grouping
  • Consistent delimiter usage throughout (both key extraction and info extraction use $arg_delimiter)
  • Clear output formatting with counts per group

The delimiter consistency issue from previous reviews has been properly addressed.


408-423: LGTM! Properly updated to use glob patterns.

The find-latest function has been correctly updated to use arg_glob instead of regex patterns, maintaining consistency with the tool's new glob-based filtering approach.


469-523: LGTM! Well-structured option parsing with proper validation.

The option parsing extensions are well-implemented:

  • Consistent variable naming (using arg_glob throughout)
  • Proper validation for numeric --keep parameter
  • Clear error messages for invalid inputs
  • Good organization of new options

The variable consistency issues from previous reviews have been resolved.


591-612: LGTM! Proper command validation with consistent variable usage.

The command validation logic is well-implemented:

  • Consistent use of arg_glob variable throughout
  • Appropriate default values for new options
  • Proper sourcing of git-sh-setup for commands that need it
  • Clear validation messages

The variable consistency issues mentioned in previous reviews have been properly addressed.


629-629: LGTM! Proper variable standardization.

Good fix to standardize the quiet flag variable usage with a proper default value.

_tests.sh (6)

4-65: LGTM! Excellent documentation and proper argument validation.

The new usage function and option handling are well-implemented:

  • Comprehensive documentation for test structure and usage
  • Proper validation for --testcase argument (addresses previous review feedback)
  • Clear error messages and help text
  • Good organization of command-line options

This significantly improves the script's usability and maintainability.


93-104: LGTM! Improved test setup automation.

The enhanced testcase_header function properly handles test directory and reference log creation, making the test framework more robust and self-sufficient.


107-110: LGTM! Good modularization of common functionality.

The generate_git_test_log helper function properly encapsulates the test log generation logic, reducing code duplication and ensuring consistency across test cases.


417-432: Good implementation, but depends on fixing function names.

The dynamic test discovery properly uses mapfile (addressing previous review feedback) and has good error handling for invalid test cases. However, the regex pattern ^[0-9]+(\.[0-9]+)?$ will need to be updated to ^test_[0-9]+(_[0-9]+)?$ once the function names are fixed to be valid Bash identifiers.

This implementation is sound but blocked by the function naming issue identified above.


206-206: LGTM! Proper shell quoting implemented.

The shell quoting issues from previous reviews have been properly addressed. Variables and command substitutions are now correctly quoted to prevent word splitting and path expansion issues.

Also applies to: 222-222, 236-236


319-415: LGTM! Well-structured tests for new functionality.

The new test cases (7, 8, 9) for the list, summary, and prune commands are well-implemented:

  • Proper test setup and cleanup
  • Good use of helper functions
  • Appropriate test scenarios that exercise the new functionality
  • Consistent with existing test patterns

These tests will provide good coverage for the new commands once the function naming issue is resolved.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bicschneider/issue17-list-n-summary-functions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
_tests.sh (1)

415-415: Use mapfile to safely capture function names.

The current approach could split function names incorrectly if they contain spaces (though unlikely).

Apply this safer approach:

-    test_functions=($(declare -F | awk '{print $3}' | grep -E '^[0-9]+(\.[0-9]+)?$'))
+    mapfile -t test_functions < <(declare -F | awk '{print $3}' | grep -E '^[0-9]+(\.[0-9]+)?$')
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed82cc8 and 69e6586.

⛔ Files ignored due to path filters (3)
  • .test/7/git-reference.log is excluded by !**/*.log
  • .test/8/git-reference.log is excluded by !**/*.log
  • .test/9/git-reference.log is excluded by !**/*.log
📒 Files selected for processing (2)
  • _tests.sh (4 hunks)
  • git-artifact (9 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
_tests.sh

[warning] 202-202: Quote this to prevent word splitting.

(SC2046)


[warning] 218-218: Quote this to prevent word splitting.

(SC2046)


[warning] 232-232: Quote this to prevent word splitting.

(SC2046)


[warning] 251-251: Quote this to prevent word splitting.

(SC2046)


[warning] 287-287: Quote this to prevent word splitting.

(SC2046)


[warning] 304-304: Quote this to prevent word splitting.

(SC2046)


[warning] 323-323: Quote this to prevent word splitting.

(SC2046)


[warning] 350-350: Quote this to prevent word splitting.

(SC2046)


[warning] 386-386: Quote this to prevent word splitting.

(SC2046)


[warning] 415-415: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

(SC2207)

🔇 Additional comments (7)
git-artifact (4)

79-81: LGTM! Clear command descriptions added.

The new commands list, summary, and prune are well-documented in the help text.


373-378: LGTM! Clean implementation of the list command.

The function correctly lists tags matching the glob pattern and provides a count.


476-519: LGTM! Well-structured option parsing.

The new options are properly handled with appropriate validation, especially the numeric check for --keep.


587-612: LGTM! Consistent command dispatch implementation.

All new commands properly validate their required options and source necessary dependencies.

_tests.sh (3)

4-31: Excellent documentation and usage function!

The comprehensive usage instructions make it easy for contributors to understand how to add and run tests.


167-411: Excellent test refactoring with modular design!

The conversion to individual test functions with dynamic discovery greatly improves maintainability. The consistent use of testcase_header and eval_testcase ensures uniformity across all tests.


377-411: Well-designed test for the prune functionality!

Test 9 effectively validates both dry-run and actual prune operations, ensuring the correct number of tags are retained.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
git-artifact (2)

341-371: This issue was already identified in previous reviews.

The word splitting issue on line 369 with $tags_to_be_pruned and the lack of empty value checking has already been flagged in previous reviews.


380-407: This delimiter inconsistency issue was already identified.

The inconsistent delimiter usage between key extraction (hardcoded "/") and info extraction ($delimiter variable) on lines 403-404 has already been flagged in previous reviews.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 69e6586 and 7f109b2.

📒 Files selected for processing (1)
  • git-artifact (9 hunks)
🔇 Additional comments (9)
git-artifact (9)

79-93: LGTM! Clear documentation for new commands.

The help text additions appropriately document the new list, summary, and prune commands along with their associated options. The formatting is consistent with the existing help structure.


477-477: LGTM! Consistent flag assignment.

The change to set arg_quiet=1 is consistent with other boolean flag handling in the script.


482-487: LGTM! Proper option parsing for new flags.

The parsing for --dryrun and --verbose options is implemented correctly with appropriate variable assignments.


504-519: LGTM! Good input validation for numeric parameter.

The option parsing for --glob and --keep is well implemented. The numeric validation for --keep using regex is a good security practice to prevent injection attacks.


373-378: LGTM! Well-structured list command implementation.

The cmd_list function properly implements tag listing with appropriate quiet mode handling and summary output. The use of glob patterns is consistent with the updated approach.


412-412: LGTM! Consistent migration to glob patterns.

The change from regex to glob pattern usage in the find-latest function is consistent with the overall refactoring to use glob patterns throughout the tool.


421-421: LGTM! Updated error message reflects new functionality.

The error message correctly refers to "glob pattern" instead of the previous regex terminology, maintaining consistency with the updated implementation.


456-456: LGTM! Helpful debug output addition.

Adding debug output for the debug variable itself is useful for troubleshooting the debug functionality.


627-627: LGTM! Proper default value handling.

The debug output for arg_quiet with default value 0 is well implemented and consistent with bash best practices for handling potentially unset variables.

@bicschneider bicschneider force-pushed the bicschneider/issue17-list-n-summary-functions branch from 7f109b2 to 1f66951 Compare August 1, 2025 21:10
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (2)
git-artifact (2)

341-371: Critical issue: Unquoted variable can cause command injection.

Line 369 uses an unquoted variable $tags_to_be_pruned which can cause word splitting and command failures. This is the same issue identified in the past review comments.

Additionally, there are logic issues:

  • Line 369 will fail if tags_to_be_pruned is empty
  • The function doesn't handle the case when no tags match the glob pattern properly

Apply this fix:

-        echo $tags_to_be_pruned | xargs git push origin --delete 
+        if [[ -n "$tags_to_be_pruned" ]]; then
+            echo "$tags_to_be_pruned" | xargs git push origin --delete
+        else
+            echo "No tags to prune"
+        fi

395-407: Critical issue: Delimiter usage inconsistency.

Line 403 uses hardcoded "/" delimiter while line 404 uses the $delimiter variable, causing inconsistent tag grouping when delimiter is not "/".

Apply this fix:

-        key="${key%%/*}"
+        key="${key%%"$delimiter"*}"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f109b2 and 1f66951.

⛔ Files ignored due to path filters (3)
  • .test/7/git-reference.log is excluded by !**/*.log
  • .test/8/git-reference.log is excluded by !**/*.log
  • .test/9/git-reference.log is excluded by !**/*.log
📒 Files selected for processing (2)
  • _tests.sh (4 hunks)
  • git-artifact (9 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
_tests.sh

[warning] 202-202: Quote this to prevent word splitting.

(SC2046)


[warning] 218-218: Quote this to prevent word splitting.

(SC2046)


[warning] 232-232: Quote this to prevent word splitting.

(SC2046)


[warning] 251-251: Quote this to prevent word splitting.

(SC2046)


[warning] 287-287: Quote this to prevent word splitting.

(SC2046)


[warning] 304-304: Quote this to prevent word splitting.

(SC2046)


[warning] 323-323: Quote this to prevent word splitting.

(SC2046)


[warning] 350-350: Quote this to prevent word splitting.

(SC2046)


[warning] 386-386: Quote this to prevent word splitting.

(SC2046)


[warning] 415-415: Prefer mapfile or read -a to split command output (or quote to avoid splitting).

(SC2207)

🔇 Additional comments (22)
git-artifact (15)

79-81: LGTM! Clear help text updates.

The help text accurately describes the new commands (list, summary, prune) that have been added to the tool.


86-93: LGTM! Option parsing enhancements.

The new options are properly documented in the help text with clear descriptions of their purposes and usage contexts.


104-112: LGTM! Proper option organization.

The options are well-organized by command context, making it clear which options apply to which commands.


373-378: LGTM! Clean implementation of list command.

The list command properly uses the glob pattern and provides useful output with tag counts.


380-393: LGTM! Good summary command implementation.

The summary command provides a useful aggregation of tags by prefix using the delimiter approach.


412-412: LGTM! Proper glob pattern usage.

The find-latest function correctly uses the glob pattern instead of regex for tag filtering.


421-421: LGTM! Consistent error messaging.

The error message correctly refers to "glob pattern" instead of regex, maintaining consistency with the updated functionality.


456-456: LGTM! Consistent debug variable usage.

The debug logging uses the consistent variable name format.


477-477: LGTM! Proper quiet flag implementation.

The quiet flag is properly set using consistent variable naming.


482-487: LGTM! New option flags implemented correctly.

The new dryrun and verbose flags are properly parsed and stored in appropriate variables.


504-507: LGTM! Glob option replaces regex.

The option parsing correctly implements the glob pattern flag, replacing the previous regex approach.


512-519: LGTM! Proper validation of keep option.

The keep option includes proper validation to ensure it's a numeric value, with appropriate error handling.


587-597: Fix inconsistent variable usage.

The code correctly uses arg_glob variable but the error message text still references the old option name.

Apply this fix:

-                    echo "ERROR: -g|--glob is required for $arg_command"
+                    echo "ERROR: -g|--glob is required for $arg_command"

Actually, looking more closely, this appears to be correct. The message is consistent with the option name.


598-612: LGTM! Proper command validation for new commands.

The new commands (summary and prune) are properly integrated into the command validation logic with appropriate option requirements.


629-629: LGTM! Consistent variable naming in debug output.

The debug output uses the consistent arg_quiet variable name.

_tests.sh (7)

4-31: LGTM! Comprehensive usage documentation.

The usage function provides excellent documentation for the test script, including clear instructions for adding new tests and understanding the test structure.


33-61: LGTM! Robust command-line argument parsing.

The argument parsing is well-implemented with proper error handling for unknown options and clear variable naming.


69-75: LGTM! Proper debug mode initialization.

The debug mode setup correctly exports variables and enables shell debugging when requested.


88-100: LGTM! Enhanced testcase_header function.

The function now automatically creates missing test directories and reference files, which improves the test setup process.


102-106: LGTM! Useful helper function for test log generation.

The generate_git_test_log function encapsulates the git log generation logic, making it reusable across tests.


115-117: LGTM! Improved test log handling.

The logic properly checks for existing test logs and uses them when available, providing good flexibility for custom test outputs.


167-411: LGTM! Excellent modularization of test cases.

The conversion of inline test blocks to individual functions is a significant improvement that enables:

  • Selective test execution via the --testcase option
  • Better maintainability and readability
  • Consistent error handling and logging

The test functions cover the new git-artifact commands (list, summary, prune) comprehensively.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (2)
git-artifact (2)

369-369: Fix potential word splitting and handle empty tag list.

The variable $tags_to_be_pruned should be quoted to prevent word splitting. Additionally, the command will fail if no tags need to be pruned.


395-407: Fix delimiter usage inconsistency in tag grouping.

The key extraction on line 403 always uses "/" as delimiter (${key%%/*}), but the info extraction on line 404 uses the $delimiter variable. This will cause incorrect grouping when delimiter is not "/".

🧹 Nitpick comments (2)
git-artifact (2)

373-378: Eliminate duplicate git ls-remote calls for efficiency.

The same git ls-remote command is executed twice, which is inefficient and could yield inconsistent results if tags change between calls.

Apply this refactor to call the command once:

 cmd_list() {
+    local tags_output
+    tags_output=$(git ls-remote --tags --ref --sort=v:refname origin "refs/tags/${arg_glob:-*}")
     if [[ ${arg_quiet:-} -ne 1 ]]; then
-        git ls-remote --tags --ref --sort=v:refname origin  "refs/tags/${arg_glob:-*}" | cut -d / -f 3-
+        echo "$tags_output" | cut -d / -f 3-
     fi
-    printf "Tags found: %s : %s\n" "${arg_glob}" "$(git ls-remote --tags --ref --sort=v:refname origin  "refs/tags/${arg_glob:-*}" | wc -l)"
+    printf "Tags found: %s : %s\n" "${arg_glob}" "$(echo "$tags_output" | wc -l)"
 }

587-610: Fix error message text for glob option.

The error message on line 592 incorrectly references "arg_glob" instead of "glob".

Apply this fix:

-                    echo "INFO: -g|--arg_glob is not set: Defaulting to '*' (all tags)."
+                    echo "INFO: -g|--glob is not set: Defaulting to '*' (all tags)."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f66951 and 43bfc67.

📒 Files selected for processing (1)
  • git-artifact (9 hunks)
🔇 Additional comments (5)
git-artifact (5)

79-81: LGTM! Help text properly documents new functionality.

The additions to the help text correctly describe the new commands and options, maintaining consistency with the existing format.

Also applies to: 87-93, 104-106, 110-112


380-393: LGTM! Summary function implementation is solid.

The function correctly uses associative arrays to group tags by prefix and provides a clear summary output.


412-412: LGTM! Glob pattern integration is consistent.

The function correctly uses arg_glob and updates error messages to reflect the change from regex to glob patterns.

Also applies to: 421-421


477-477: LGTM! Option parsing enhancements are well implemented.

The new options are correctly parsed with appropriate validation (numeric check for --keep) and consistent variable naming.

Also applies to: 482-487, 504-506, 512-519


456-456: LGTM! Debug statements properly updated.

The debug statements are consistent with the updated variable naming scheme throughout the script.

Also applies to: 627-627

@bicschneider bicschneider force-pushed the bicschneider/issue17-list-n-summary-functions branch from 43bfc67 to a26554b Compare August 1, 2025 21:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43bfc67 and a26554b.

⛔ Files ignored due to path filters (3)
  • .test/7/git-reference.log is excluded by !**/*.log
  • .test/8/git-reference.log is excluded by !**/*.log
  • .test/9/git-reference.log is excluded by !**/*.log
📒 Files selected for processing (2)
  • _tests.sh (4 hunks)
  • git-artifact (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • git-artifact
🧰 Additional context used
🪛 Shellcheck (0.10.0)
_tests.sh

[warning] 202-202: Quote this to prevent word splitting.

(SC2046)


[warning] 218-218: Quote this to prevent word splitting.

(SC2046)


[warning] 232-232: Quote this to prevent word splitting.

(SC2046)


[warning] 251-251: Quote this to prevent word splitting.

(SC2046)


[warning] 287-287: Quote this to prevent word splitting.

(SC2046)


[warning] 304-304: Quote this to prevent word splitting.

(SC2046)


[warning] 323-323: Quote this to prevent word splitting.

(SC2046)


[warning] 350-350: Quote this to prevent word splitting.

(SC2046)


[warning] 386-386: Quote this to prevent word splitting.

(SC2046)

🔇 Additional comments (1)
_tests.sh (1)

415-417: Good adoption of mapfile – array fills are now safe

Switching to mapfile -t test_functions … eliminates SC2207 word-splitting risks from the earlier implementation. Nice upgrade.

@bicschneider bicschneider force-pushed the bicschneider/issue17-list-n-summary-functions branch 3 times, most recently from 66ffb5c to 1ec7e35 Compare August 1, 2025 22:20
Breaking:
- option regex replaced with glob as was implemented as glob. regex might come later using grep as filter

New features:
- added: function "list" artifacts command with glob pattern
- added: function "summary" using delimiter (default: /) . it finds all first fields and then counts number of artifacts given the pattern
- added: function "prune". given a pattern find all artifacts and then keep the last amount given (default: 20).  It is supporting --dryrun option

Tests:
- refactor tests to functions and enable single test case execution - it is still defaulting to * if not given
- tests for new functions
@bicschneider bicschneider force-pushed the bicschneider/issue17-list-n-summary-functions branch from 1ec7e35 to 3bcc012 Compare August 2, 2025 09:07
@bicschneider bicschneider merged commit eb2c48d into main Aug 2, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pruning mechanism with a keep option Add list, summary, prune functionality

2 participants