Commit Graph

26 Commits

Author SHA1 Message Date
zhenyi 45c00b2dee fix(metrics): escape Prometheus label values and remove section dividers
Add prom_escape() to sanitize label values per Prometheus text format spec.
Remove '// ──' section dividers per project style guidelines.
2026-06-10 18:31:59 +08:00
zhenyi e582b269f1 fix(server): validate branch name in set_default_branch
Call validate_ref_name on the user-provided branch name before
constructing the symbolic-ref argument to prevent command injection.
2026-06-10 18:31:54 +08:00
zhenyi 0665772079 fix(remote): validate remote URL, name and refspecs
Call validate_remote_url, validate_ref_name, and validate_refspec before
passing user input to git subprocess in update_remote_mirror, fetch_remote,
and create_repository_from_url.
2026-06-10 18:31:50 +08:00
zhenyi 1c22700769 feat(sanitize): add remote URL and refspec validation
Add validate_remote_url() to reject non-transport schemes (file://, ext::)
and validate_refspec() to reject shell metacharacters in refspec strings.
2026-06-10 18:31:46 +08:00
zhenyi e4080dcbc7 chore: remove .env from git tracking
Add .env to .gitignore, unstage tracked .env, and create .env.example
as a template for local development.
2026-06-10 18:31:36 +08:00
zhenyi 939931acad feat(repository): add language statistics analysis feature
- Remove data directory from gitignore to include language data
- Add build script to parse linguist languages.yml and generate static mappings
- Include serde and serde_yml dependencies for YAML parsing
- Add lang_stats module with language detection and statistics calculation
- Generate protobuf definitions for language statistics API endpoints
- Implement GetLanguageStats RPC endpoint in repository server
- Add comprehensive test suite for language statistics functionality
- Include extension and filename based language detection logic
- Implement binary file classification and group resolution features
2026-06-10 13:06:59 +08:00
zhenyi 9a0c26e5f6 refactor(actor): implement Raft consensus algorithm for cluster leader election
- Add voting mechanism with term tracking and vote persistence
- Implement election triggering logic with majority vote counting
- Add primary/replica role transition handling with state management
- Integrate health check failure detection for automatic elections
- Refactor actor messaging system for distributed coordination
- Update repository registration to query cluster for existing primary
- Add broadcast mechanism for role change notifications
- Implement proper term comparison and duplicate request filtering
- Upgrade dependency versions including tokio-util for async utilities
- Optimize code formatting and line wrapping for improved readability
- Remove redundant blank lines and improve code structure consistency
- Enhance error logging and trace information for debugging purposes
2026-06-10 12:35:10 +08:00
zhenyi ab32e8826e feat(pack): add raw advertise refs and stateless protocol support
- Add raw flag to AdvertiseRefsRequest to enable raw pkt-line output
- Implement advertise_refs_raw function that calls git upload-pack/receive-pack with --advertise-refs
- Add stateless flag to GitProtocolFeatures for HTTP smart protocol support
- Modify upload_pack and receive_pack to accept stateless parameter
- Update command construction to include --stateless-rpc flag when enabled
- Add raw_data field to AdvertiseRefsResponse for raw output
- Update pack cache key computation to include raw service differentiation
- Initialize raw field to false in all request creation calls
2026-06-08 21:46:31 +08:00
zhenyi eeb4d9f902 feat(system): add systemd service and installation script
- Add gitks systemd service unit file with security sandboxing
- Create environment configuration template for gitks service
- Add logrotate configuration for gitks application logs
- Implement installation script with service user creation
- Set up proper directory permissions and file ownership
- Configure automatic service startup and systemd integration
2026-06-08 21:27:54 +08:00
zhenyi c2487ec0b6 feat(charts): add Helm chart for gitks Git bare repository service
- Create Chart.yaml with application metadata and keywords
- Add _helpers.tpl with name, fullname, labels, and DNS template functions
- Generate ConfigMap with all gitks configuration environment variables
- Implement StatefulSet with persistent volume claims for repository data
- Create headless service for pod DNS and cluster communication
- Add gRPC service for client connections and metrics service
- Include HorizontalPodAutoscaler for dynamic scaling
- Add PodDisruptionBudget to maintain cluster availability
- Create ServiceAccount with proper security context
- Add test connection pod using grpcurl for health checks
- Generate NOTES.txt with installation instructions and quick start guide
- Create .helmignore file to exclude common development files
- Configure persistence, resource limits, and security settings
- Add support for cluster mode with etcd service discovery
2026-06-08 21:21:15 +08:00
zhenyi f5044fb099 refactor(docker): optimize Docker build process and update configurations
- Replace direct Rust build with cargo-chef multi-stage build pattern
- Switch base image from debian:bookworm-slim to ubuntu:26.04
- Add .codegraph to .dockerignore and data to .gitignore
- Introduce Dockerfile.fast for faster builds without optimization
- Add comprehensive .env configuration file with cluster settings
- Create docker-compose.yaml for multi-node cluster setup
- Add cluster routing test case for distributed operations
- Remove unnecessary success status checks in repository maintenance
- Fix error handling in git command executions by properly propagating errors
- Add repository move protection to prevent self-destruct operations
- Simplify conditional logic in actor message validation
- Update remote pack client calls with proper error handling parameters
2026-06-08 18:52:22 +08:00
zhenyi 66afd932ed feat(api): extend commit and diff services with new functionality
- Add FindCommit, ListCommitsByOid, CommitIsAncestor RPCs to CommitService
- Add CheckObjectsExist, CommitsByMessage, GetCommitStats RPCs to CommitService
- Add LastCommitForPath, CountCommits, CountDivergingCommits RPCs to CommitService
- Add RawDiff, RawPatch, FindChangedPaths RPCs to DiffService
- Add FindMergeBase, WriteRef, SearchFilesByContent RPCs to RepositoryService
- Add SearchFilesByName, ObjectsSize, RepositorySize RPCs to RepositoryService
- Add FindLicense, OptimizeRepository, GetRawChanges RPCs to RepositoryService
- Add FetchRemote, CreateRepositoryFromURL RPCs to RepositoryService
- Implement server handlers for all new RPC methods
- Add new modules for commit counting, finding, and querying features
- Add new modules for diff changed paths and raw operations
- Add new modules for refs and remote operations
- Remove unnecessary comments from various source files
- Update proto definitions with new message types and service methods
2026-06-08 15:37:08 +08:00
zhenyi 8f472a0443 feat(cluster): implement distributed clustering with etcd coordination
- Integrate etcd-client for distributed coordination and leader election
- Add remote client macros with proper formatting for all services
- Implement RequestMetrics for tracking RPC performance and errors
- Add rate limiting mechanism across all service endpoints
- Create ElectionRequest and ElectionResult message types for leader election
- Add role management with primary/replica switching capabilities
- Implement health checker with automatic failover detection
- Add repository count metrics for cluster monitoring
- Update Cargo.toml with etcd-client and dashmap dependencies
- Modify RepoEntry to include read_only flag for replica handling
- Implement should_accept_election logic to prevent duplicate elections
- Add RoleChangedEvent handling for cluster role updates
2026-06-08 14:31:29 +08:00
zhenyi d243dce027 refactor(server): replace custom remote clients with macro-based implementation
- Replaced manual remote client functions with remote_client! macro for archive, blame, branch, commit, and diff services
- Simplified remote client creation logic using declarative macro approach
- Maintained same functionality while reducing code duplication across services

security(bare): enhance path traversal protection with comprehensive validation

- Added early relative_path validation to prevent path traversal attacks
- Implemented unified path validation to avoid TOCTOU race conditions
- Enhanced canonicalization checks for both existing and non-existent paths
- Added detailed logging for path traversal detection attempts

feat(cache): migrate from CLruCache to Moka with TTL and invalidation support

- Replaced clru dependency with moka for improved caching capabilities
- Added 300-second time-to-live for cache entries
- Implemented repository-specific cache invalidation mechanism
- Enhanced cache operations with thread-safe async support

refactor(commit): improve security validation for commit operations

- Added ref name validation to prevent command injection in cherry_pick_commit
- Implemented revision validation for commit selectors
- Added comprehensive input validation for create_commit parameters
- Enhanced file path validation to prevent traversal
2026-06-08 09:43:57 +08:00
zhenyi 8c95eb230d refactor(actor): implement replica sync and ref update notification system
- Add is_write parameter to remote clients for read/write routing distinction
- Introduce RepoEntry struct with role tracking (primary/replica) for repositories
- Replace HashSet with HashMap for repository storage with role metadata
- Add ROLE_PRIMARY and ROLE_REPLICA constants for node role identification
- Implement FindPrimary and FindReplica RPC methods for role-based routing
- Add RefUpdateEvent message type for propagating reference updates
- Create sync module with BundleApplicator for handling replica synchronization
- Implement notify_ref_update calls after branch/tag/commit operations
- Add broadcast_ref_update function to propagate events across cluster nodes
- Modify route_repository to prioritize primary for writes and replicas for reads
- Update actor message handling to support role-based repository discovery
- Implement sync_from_primary function using pack protocol for incremental updates
2026-06-08 01:54:08 +08:00
zhenyi 5c99b27421 feat(gateway): implement remote service forwarding for distributed git operations
- Add remote client functions for archive, blame, and branch services
- Implement fallback logic to forward requests to remote storage nodes
- Add logging for forwarding operations with route details
- Update Cargo.lock with new dependencies including ractor cluster libraries
- Extend .gitignore with IDE and build system files
- Remove outdated comments from bare repository implementation
2026-06-08 01:21:20 +08:00
zhenyi 5b740eecd7 chore(deps): update dependencies and migrate to tonic-prost
- Replace tonic-build with tonic-prost-build in build dependencies
- Update clru from 0.6.3 to 0.6
- Update serde from 1.0.228 to 1.0
- Update gix from 0.84.0 to 0.84
- Update gix-archive from 0.33.0 to 0.33
- Update duct from 1.1.1 to 1.0
- Update tracing from 0.1.32 to 0.1
- Update tokio-stream from 0.1.18 to 0.1
- Update thiserror from 2.0.18 to 2.0
- Update prost from 0.13 to 0.14
- Update prost-types from 0.13 to 0.14
- Update tonic from 0.12 to 0.14 with transport feature
- Add tonic-prost dependency at version 0.14
- Update tonic-prost-build in build dependencies from 0.12 to 0.14
- Remove async-stream and async-stream-impl dependencies
- Update axum from 0.7.9 to 0.8.9
- Update various other transitive dependencies including getrandom, indexmap, hashbrown, socket2, log, matchit, petgraph, tower, and windows-sys related packages
2026-06-04 18:07:17 +08:00
zhenyi a815f63927 chore: update gitignore and remove ide configuration files
- Add .idea directory to .gitignore
- Remove .idea/.gitignore file
- Remove .idea/gitks.iml module file
- Remove .idea/modules.xml project modules configuration
- Remove .idea/vcs.xml version control system mapping
- Clean up IDE-specific configuration files from repository
2026-06-04 17:48:17 +08:00
zhenyi 7631e57f69 test(bare): add comprehensive tests for GitBare functionality
- Add test_from_header_valid to verify valid repository header parsing
- Add test_from_header_empty_path to handle empty path scenarios
- Add test_from_header_relative_storage_path to validate absolute paths
- Add test_from_header_relative_path_without_storage for missing storage
- Add test_from_header_nonexistent_repo to check repo existence
- Add test_from_header_path_traversal to prevent directory traversal
- Add test_from_header_not_a_directory for file instead of directory
- Add test_from_header_dir_without_head to verify bare repository format
- Add test_object_format to validate object format detection
- Add test_oid_to_pb to verify OID conversion functionality
- Add test_oid_to_pb_invalid_hex to handle invalid hex input gracefully

test(error): add comprehensive error handling tests

- Add test_error_display_variants to verify error message formatting
- Add test_error_is_debug to
2026-06-04 15:33:33 +08:00
zhenyi cc202d6d1f feat(server): add tracing spans and caching to archive and blame services
- Add tracing spans with repo labels for archive and blame operations
- Implement caching for archive list entries when using OID selectors
- Implement caching for blame operations when using OID selectors
- Add detailed
2026-06-04 15:33:16 +08:00
zhenyi 729604f13b feat(server): add repository prefix path configuration and service struct
- Add REPO_PREFIX_PATH environment variable support in Dockerfile and main.rs
- Introduce GitksService struct with repo_prefix field to manage repository paths
- Implement resolve and resolve_for_init methods for repository path handling
- Add path traversal protection and validation for repository operations
- Update all service implementations to use self.resolve instead of global resolve
- Modify serve function to accept repo_prefix parameter and pass to GitksService
- Remove global resolve functions and integrate them into GitksService struct
- Add proper initialization of repo directory from environment variable
2026-06-04 14:18:12 +08:00
zhenyi 4a87ea475d feat(build): add Docker support for gitks application
- Add .dockerignore file to exclude unnecessary files from Docker build context
- Create multi-stage Dockerfile with rust builder and debian runtime stages
- Configure environment variables for host and port settings
- Set up proper EXPOSE and ENTRYPOINT instructions
- Optimize build with cargo release and binary stripping
- Install only required dependencies in production stage
2026-06-04 14:11:55 +08:00
zhenyi f0a443932a feat(server): add gitks gRPC server with environment configuration
- Add dotenvy dependency for environment variable loading
- Integrate tracing-subscriber for structured logging
- Create main.rs entry point with async server initialization
- Implement environment-based host and port configuration
- Set default address to 0.0.0:50051 for gRPC server
- Add proper error handling with Box<dyn std::error::Error>
2026-06-04 14:10:29 +08:00
zhenyi 998f393ed0 feat(server): add comprehensive Git repository services with test coverage
- Implement ArchiveService for repository archive operations
- Add BlameService for Git blame functionality
- Create BranchService with full branch management capabilities
- Integrate CommitService for commit operations and history
- Add DiffService for generating diffs and patches
- Implement MergeService with conflict resolution features
- Add PackService for Git packfile operations
- Create TagService for Git tag management
- Add TreeService for Git tree operations
- Implement comprehensive repository management functions
- Add repository statistics and health checking capabilities
- Include garbage collection and repacking operations
- Add repository configuration management
- Implement error handling and status conversion utilities
- Add test suite covering all repository operations
- Create utility functions for Git command execution
- Add streaming response support for large data operations
- Implement request resolution and validation helpers
2026-06-04 14:10:21 +08:00
zhenyi 737e934043 feat(tree): add recent commit metadata and LFS support to file metadata
- Added RecentCommit message definition with oid, subject and timestamp fields
- Extended TreeEntry, Tree, and FileMetadata messages with is_lfs and recent_commit fields
- Updated get_file_metadata function to include recent commit information
- Added tree module import and recent_commit lookup functionality
- Updated protobuf definitions to include new metadata fields
- Enhanced file metadata response with LFS status and commit history
2026-06-04 13:47:46 +08:00
zhenyi dcb0fb74c5 feat(core): implement Git repository operations with gRPC services
- Add advertise_refs functionality for Git protocol communication
- Implement archive service with TAR/ZIP format support and streaming
- Create blame service for Git file annotation with line tracking
- Add branch management including create, delete, rename and compare operations
- Implement merge checking with conflict detection and fast-forward handling
- Add cherry-pick functionality for applying commits between branches
- Integrate gix library for Git repository operations and object handling
- Add comprehensive test suite covering all Git operations
- Implement proper error handling and repository validation
- Add pagination support for large result sets
- Create protobuf definitions for all Git operations and data structures
- Add build system for gRPC code generation and dependency management
2026-06-04 13:05:38 +08:00