This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Git Artifact is a PHP CLI tool that packages code artifacts from a source repository and pushes them to a destination repository. It's designed for deployment workflows where built artifacts need to be deployed to a separate repository.
composer lint- Run code quality checks (PHPCS, PHPStan, Rector dry-run)composer lint-fix- Fix code quality issues (Rector, PHPCBF)
composer test- Run PHPUnit tests without coveragecomposer test-coverage- Run PHPUnit tests with coverage
composer build- Build standalone PHAR executable using Box
- ArtifactCommand (
src/Commands/ArtifactCommand.php) - Main CLI command that orchestrates the artifact creation process - ArtifactGitRepository (
src/Git/ArtifactGitRepository.php) - Extended Git repository class with artifact-specific operations - Traits (
src/Traits/) - Reusable functionality:TokenTrait- Handle token replacement in branch names and commit messagesLoggerTrait- Logging functionalityFilesystemTrait- File system operations
git-artifact- Main executable script with autoloader discoverysrc/app.php- Application bootstrap using Symfony Console
The tool supports two deployment modes:
- force-push (default) - Pushes to same branch, overwrites destination history
- branch - Creates new branches in destination based on source tags
Supports dynamic token replacement in branch names and commit messages:
[timestamp:FORMAT]- Current timestamp with PHP date format[branch]- Current branch name[safebranch]- Branch name with non-alphanumeric chars replaced[tags:DELIMITER]- Tags from latest commit
Integration tests that verify end-to-end functionality:
BranchModeTest.php- Tests branch mode deploymentForcePushModeTest.php- Tests force-push mode deploymentGeneralTest.php- General functionality testsTagTest.php- Token replacement and tagging tests
- Component-level tests for individual classes
- Follow PHPUnit conventions with strict typing
f*- Files with counter suffixi- Ignored filesc- Committed filesu- Uncommitted filesd- Deleted filesd_- Directoriessub_- Sub-directories/files for wildcard testingf*_l- Symlinks
- Follows Drupal coding standards via PHPCS
- Uses PHPStan level 9 for static analysis
- Rector for automated code modernization to PHP 8.2+
- PSR-4 autoloading:
DrevOps\GitArtifact\namespace maps tosrc/
symfony/console- CLI frameworkczproject/git-php- Git operationssymfony/filesystem&symfony/finder- File operationsmonolog/monolog- Logging
Run specific test classes:
./vendor/bin/phpunit tests/Unit/TokenTest.php
./vendor/bin/phpunit tests/Functional/BranchModeTest.phpRun specific test methods:
./vendor/bin/phpunit --filter testTokenReplacement tests/Unit/TokenTest.php