DGT (Dart Gerrit Tool) is a command-line interface designed specifically for Dart SDK contributors to efficiently manage their local branches and track their Gerrit code review status. The tool provides a unified view of local Git repository state alongside corresponding Gerrit change information.
Enable Dart SDK contributors to quickly understand the status of all their development branches in relation to Gerrit code reviews, reducing context switching and manual lookups between local Git repository and Gerrit web interface.
- Primary: Dart SDK contributors who use Gerrit for code review
- Secondary: Developers working with Git repositories that have Gerrit integration
User Story: As a contributor, I want to see all my local branches with their corresponding Gerrit review status in one place.
Requirements:
- Display all local Git branches
- Show Gerrit status for each branch (WIP, Active, Merged, Abandoned, Merge conflict)
- Indicate branches without Gerrit association (local-only)
- Color-coded output for quick visual identification
User Story: As a contributor, I want to know when my local branch differs from what's uploaded to Gerrit.
Requirements:
- Detect when local commits haven't been uploaded to Gerrit
- Detect when Gerrit has updates not reflected locally
- Highlight differences in hash and date columns
- Clear visual indicators for sync status
User Story: As a contributor working on multiple features, I want to filter branches to focus on specific work.
Requirements:
- Filter by Gerrit status (active, wip, merged, etc.)
- Filter by date range (since/before specific dates)
- Filter by divergence state (only branches with differences)
- Support multiple filter combinations
User Story: As a regular user, I want to save my preferred display and filter settings.
Requirements:
- Persistent configuration storage
- Default display options (show/hide columns)
- Default filter preferences
- Configuration reset capability
User Story: As a contributor with many branches, I want fast execution times.
Requirements:
- Batch API queries to minimize network requests
- Parallel Git operations
- Optional performance timing display
Core Functionality:
- Discovers all local Git branches
- Queries Gerrit for change status via batch API calls
- Displays information in formatted table with columns:
- Branch Name
- Status (WIP, Active, Merged, Abandoned, Merge conflict, -)
- Local Hash (first 8 chars)
- Local Date
- Gerrit Hash (first 8 chars)
- Gerrit Date
- Optional: Gerrit URL
Status Mapping:
WIP: Changes marked as work-in-progressActive: Changes ready for review (NEW status in Gerrit)Merged: Successfully merged changesAbandoned: Abandoned changes in GerritMerge conflict: Changes that cannot be merged-: No Gerrit change associated (local-only branch)
Performance Features:
- Batch Git operations using
git for-each-ref - Batch Gerrit API queries (up to 10 changes per request)
- Parallel processing with isolates
- Result caching to avoid redundant operations
Column Control:
--gerrit/--no-gerrit: Show/hide Gerrit columns--local/--no-local: Show/hide local Git columns--url: Include Gerrit URL column
Output Enhancement:
--verbose: Detailed execution information--timing: Performance breakdown display- Color coding for status and divergence indicators
Status Filtering:
--status <status>: Filter by specific Gerrit status- Multiple status values supported
- Special values:
gerrit(all Gerrit statuses),local(no Gerrit config)
Date Filtering:
--since <date>: Branches with commits after specified date--before <date>: Branches with commits before specified date- ISO 8601 date format support
Divergence Filtering:
--diverged: Show only branches with local or remote differences
Sort Fields:
local-date: Local commit dategerrit-date: Gerrit update datestatus: Gerrit statusdivergences: Divergence state (both, one side, in sync)name: Branch name (default)
Sort Directions:
--asc: Ascending order (default)--desc: Descending order
Save Defaults:
- Display preferences (column visibility)
- Filter preferences (status, divergence, date ranges)
- Sort preferences (field and direction)
Configuration Operations:
- Save new configuration
- Remove specific options (
--no-status,--no-sort) - View current configuration
- Reset to defaults (
dgt config clean)
Storage:
- Configuration file:
~/.dgt/.config - JSON format for easy parsing
- Cross-platform path resolution
Functionality:
- Wrapper around
git cl archivecommand - Passes all arguments directly to underlying command
- Maintains consistent verbose output and timing options
Repository Detection:
- Automatic Git repository validation
- Support for custom repository paths (
--path) - Error handling for non-Git directories
Gerrit Configuration Extraction:
- Reads
.git/configfor Gerrit metadata:branch.<name>.gerritissue: Change numberbranch.<name>.gerritserver: Gerrit server URLbranch.<name>.gerritpatchset: Patchset numberbranch.<name>.gerritsquashhash: Squash hashbranch.<name>.last-upload-hash: Last uploaded commit
Change-ID Fallback:
- Extracts Change-IDs from commit messages when config missing
- Format:
Change-Id: I[40 hex characters]
Batch Query System:
- Queries up to 10 changes per API request
- Handles Gerrit's XSSI protection (
)]}'prefix) - Isolate-based processing for performance
- Graceful error handling with partial results
API Endpoints:
- Primary:
/changes/?q=<query>&o=CURRENT_REVISION&o=LABELS&o=MESSAGES&o=REVIEWERS - Server:
https://dart-review.googlesource.com(Dart SDK default)
Data Extraction:
- Status mapping from Gerrit API responses
- LGTM (Code-Review) vote counting
- Commit-Queue status detection
- Message and reviewer information
- Batch Operations: Minimize Git process spawns and API requests
- Parallel Processing: Use Dart isolates for concurrent operations
- Caching: Cache Git command results within single execution
- Error Handling: Graceful degradation when API or Git operations fail
- Partial Results: Continue processing when some operations fail
- Input Validation: Validate all user inputs (dates, status values, etc.)
- Clear Output: Color-coded, tabular display with alignment
- Help System: Comprehensive help text and usage examples
- Error Messages: Descriptive error messages with suggested fixes
- Gerrit API batch query limit: 10 changes per request
- Rate limiting considerations
- Network dependency for Gerrit queries
- Requires Git installation and repository context
- Depends on specific
.git/configformat for Gerrit metadata - Limited to repositories with Gerrit integration
- User-level configuration only (no repository-specific config)
- Single configuration file format
- No remote configuration synchronization
This PRD focuses on existing implemented features. The tool provides a solid foundation for potential enhancements while maintaining its core value proposition of efficient branch and review status management for Dart SDK contributors.