Skip to content

Conversation

@itlackey
Copy link
Contributor

Refactoring to subcommand scripts for 0.4.p

Test and others added 8 commits July 22, 2025 18:18
- Simplified the main entry script (`src/giv.sh`) to focus on global options and delegate subcommands to individual scripts in `src/commands/`.
- Created dedicated scripts for each subcommand (e.g., `announcement.sh`, `changelog.sh`, `document.sh`, etc.) to handle specific logic and argument parsing.
- Implemented shared argument parsing for document-related subcommands in `document_args.sh`.
- Enhanced error handling throughout the codebase, including checks for file existence and command execution success.
- Updated `src/project/metadata.sh` to read metadata from `.giv/config` and improved the initialization process.
- Added a configuration file (`config`) with examples and documentation for various settings.
- Improved the `build_history` and `get_commit_date` functions in `history.sh` to provide better error messages and handling.
- Documented the changes and provided a detailed guide for the new subcommand structure in `docs/features/subcommands_refactor.md`.
… environment variable overrides; add comprehensive tests for config and summary commands.
- Removed the provider_python_toml.sh script as it is no longer needed.
- Added load_env_file function in system.sh to load environment variables from .env files in the current directory or git root.
- Updated test files to reflect changes in project structure and loading of metadata.
- Consolidated metadata extraction logic into project_metadata.sh for better maintainability.
- Enhanced version extraction tests to ensure compatibility with new metadata functions.
- Deleted obsolete test files related to removed provider scripts.
- Introduced glow.sh for managing the installation of the glow CLI tool.
- Improved the `parse_args` function in `args.sh` to handle configuration file loading more robustly and to ensure that the correct values are set for API model, URL, and key.
- Enhanced the `config.sh` command to normalize keys and improve error handling for missing configuration files.
- Updated `history.sh` to source configuration and project metadata conditionally based on the test environment.
- Modified `llm.sh` to handle API responses more gracefully, including improved error messages and content extraction using `jq` if available.
- Added a utility function in `markdown.sh` to conditionally use `glow` for markdown output.
- Improved project metadata extraction logic in `project_metadata.sh` to ensure project type detection is consistent and robust.
- Enhanced temporary file creation in `system.sh` to ensure proper cleanup and handling of temporary files.
- Updated tests in `summarize_commit.bats`, `summarize_target.bats`, `test_parse_args.bats`, and `test_version_extraction.bats` to ensure proper setup and teardown, including configuration file creation for consistent test behavior.
fix: enhance metadata retrieval with additional commit options and error handling

test: initialize git repository in test setup for consistent environment

refactor: rename GIV_METADATA_PROJECT_TYPE to GIV_PROJECT_TYPE for clarity

test: update version extraction tests to use new project type variable

test: implement integration tests for dispatcher functionality

test: create integration tests for subcommands with various scenarios

test: add comprehensive workflow integration tests for end-to-end scenarios

chore: maintain consistent project structure and improve test coverage
@itlackey itlackey requested a review from Copilot July 24, 2025 08:54
@itlackey itlackey self-assigned this Jul 24, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request implements a comprehensive refactoring of the giv CLI into subcommand scripts for version 0.4.p, transforming the monolithic architecture into a modular command structure with dedicated initialization and configuration management.

  • Refactored main dispatcher to delegate to individual subcommand scripts located in src/commands/
  • Consolidated initialization logic into src/init.sh and created centralized metadata extraction via src/project_metadata.sh
  • Updated all tests to use the new modular structure with improved test fixtures and integration test suites

Reviewed Changes

Copilot reviewed 59 out of 61 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/giv.sh Simplified main dispatcher that delegates to subcommand scripts
src/commands/*.sh New modular subcommand scripts for config, message, summary, changelog, etc.
src/init.sh Centralized initialization logic for environment setup
src/project_metadata.sh Unified metadata extraction replacing provider-based system
tests/* Updated test structure with new integration tests and improved fixtures
Comments suppressed due to low confidence (2)

tests/test_version_extraction.bats:52

  • The variable name GIV_PROJECT_TYPE is inconsistent with GIV_METADATA_PROJECT_TYPE used elsewhere in the codebase. Consider standardizing to one naming convention.
    export GIV_PROJECT_TYPE="custom"

tests/integration_workflow.bats:506

  • The timeout test may produce inconsistent results in different environments. Consider using a more predictable method to test network failure handling.
    run timeout 5s "$GIV_SCRIPT" message HEAD --dry-run 2>/dev/null || true

Test added 15 commits July 24, 2025 15:35
…rsing

- Removed the deprecated commands.sh file, consolidating its functionality into individual command scripts.
- Updated changelog.sh to source document_args.sh from the GIV_LIB_DIR for better organization.
- Removed redundant initialization of variables in document.sh and eliminated the now-unnecessary document_args.sh file.
- Modified message.sh to parse positional arguments directly from the updated argument parsing function.
- Enhanced summary.sh to streamline command delegation.
- Deleted config.sh and moved its configuration variables to system.sh for better structure.
- Improved error handling in llm.sh for empty API responses.
- Updated system.sh to include project type detection logic and configuration management.
- Added version.sh to display the current version of the GIV CLI.
- Refactored tests to remove dependencies on the now-removed config.sh, ensuring they load only necessary modules.
- Enhanced integration tests to cover new configurations and ensure robust error handling.
- Consolidated argument parsing logic into a unified module (`argument_parser.sh`) for improved maintainability and clarity.
- Updated `giv.sh` to utilize the new argument parser, ensuring consistent handling of global options and subcommands.
- Enhanced error handling for missing files and invalid commits in `project_metadata.sh`.
- Modified temporary file handling in `history.sh` and `system.sh` to avoid traps, delegating cleanup responsibility to the caller.
- Improved test cases in `test_parse_args.bats` to align with the new unified parser structure, including updates to subcommand validation and output assertions.
- Adjusted version extraction tests to use the correct environment variable for project type.
- Added backup scripts for previous argument parsing methods for potential rollback.
…workflows

- Implement integration tests for individual subcommands including config, message, summary, changelog, and release-notes.
- Create end-to-end workflow tests to simulate complete development cycles, including feature development, multi-commit workflows, hotfixes, and project configuration management.
- Introduce argument parsing tests to validate command-line options and subcommand handling.
- Mock AI responses for various contexts to ensure consistent test outputs.
- Enhance error handling tests to cover invalid git references and missing configurations.
- Implement pathspec filtering tests to validate selective change processing.
- Add performance and caching tests to evaluate efficiency in repeated command executions.
- Ensure cleanup and maintenance tests verify no temporary files are left behind after execution.
- Added pypi-validator.sh for validating PyPI package installations across platforms.
- Introduced rpm-validator.sh for testing RPM package installations on RPM-based systems.
- Created test-framework.sh to validate the overall testing framework functionality.
- Enhanced validate-installs.sh to improve cleanup process after tests.
- Documented build system improvements and validation processes in build-system-todos.md and build-system-validation-todos.md.
- Developed detailed guide on building, validating, and publishing GIV CLI in how-to-publish.md.
- Added `validate-installs-container.sh` to handle package validation inside a Docker container.
- Refactored `validate-installs.sh` to orchestrate the containerized validation process.
- Updated documentation to reflect the new containerized architecture and usage instructions.
- Enhanced validation reporting with JSON output options.
- Streamlined package installation tests for deb, pypi, npm, homebrew, and snap.
- Improved error handling and reporting for validation failures.
- Removed legacy validation logic from `validate-installs.sh` to simplify the script.
- Added global argument parser to handle global options and subcommand detection in the CLI.
- Introduced new environment variables for temperature and context window size for AI responses.
- Improved the configuration management script to support additional commands and better error handling.
- Implemented argument parsing for the changelog, document, and message subcommands, allowing for more flexible command usage.
- Enhanced the summary command to work with real Git repositories and added tests for various edge cases.
- Updated tests to cover new functionality and ensure robust error handling across commands.
- Created a new configuration file format to streamline project settings and API configurations.
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.

3 participants