Skip to content

Conversation

@jordanpartridge
Copy link
Contributor

Summary

Implements a comprehensive label management system with support for creating, updating, deleting, and querying labels at both the repository and issue level with a fluent API for batch operations and color management.

Closes #23

Changes

Label DTO Enhancements

  • Added default field to Label DTO to track default labels
  • Implemented hexColor() method to get color with # prefix
  • Implemented isLightColor() method to detect light/dark colors using brightness calculation

Repository-Level Label Management

  • RepositoryLabelManager - Manages labels at repository level
    • all() - Get all repository labels
    • find(string $name) - Get a specific label
    • create(string $name, string $color, ?string $description) - Create new label
    • update(string $name, array $attributes) - Update existing label
    • delete(string $name) - Delete a label
    • sync(array $labels) - Sync labels from array (create/update/delete)
    • builder() - Get fluent builder instance

Issue-Level Label Management

  • IssueLabelManager - Manages labels on specific issues
    • all() - Get all labels for an issue
    • add(string|array $labels) - Add single or multiple labels
    • remove(string $label) - Remove a label
    • set(array $labels) - Replace all labels
    • clear() - Remove all labels

Fluent Label Builder

  • LabelBuilder - Fluent API for creating labels
    • name(string $name) - Set label name
    • color(string $color) - Set custom color
    • description(string $description) - Set description
    • Predefined GitHub color presets:
      • red() - d73a4a (bugs, critical)
      • orange() - d4a72c (warnings)
      • yellow() - fef2c0 (needs attention)
      • green() - 0e8a16 (improvements)
      • blue() - 1d76db (information)
      • purple() - 5319e7 (questions)
      • pink() - e99695 (design)
      • gray() - d1d5da (stale)
    • create() - Execute label creation

Request Classes

Created 10 new Saloon Request classes for GitHub API integration:

  • Repository Labels: List, Get, Create, Update, Delete
  • Issue Labels: List, Add, Remove, Set, Clear

Usage Examples

use ConduitUI\Issue\Services\RepositoryLabelManager;

// Repository-level operations
$manager = new RepositoryLabelManager($connector, 'owner/repo');
$labels = $manager->all();
$label = $manager->create('bug', 'd73a4a', 'Something is broken');
$manager->update('bug', ['color' => 'ff0000']);
$manager->delete('old-label');

// Fluent builder
$label = $manager->builder()
    ->name('priority-high')
    ->red()
    ->description('High priority issue')
    ->create();

// Sync labels
$manager->sync([
    ['name' => 'bug', 'color' => 'd73a4a', 'description' => 'Bug'],
    ['name' => 'feature', 'color' => '1d76db', 'description' => 'Feature'],
]);

// Issue-level operations
$issueManager = new IssueLabelManager($connector, 'owner/repo', 123);
$issueManager->add(['bug', 'priority-high']);
$issueManager->remove('wontfix');
$issueManager->set(['bug', 'verified']);
$issueManager->clear();

Testing

  • 100% test coverage achieved
  • All tests passing (284 tests)
  • PHPStan level max compliance (0 errors)
  • Code formatted with Laravel Pint

Quality Gates

✓ composer test           # 284 tests passing
✓ pest --coverage --min=100   # 100% coverage
✓ vendor/bin/phpstan analyse  # 0 errors
✓ vendor/bin/pint         # Code formatted

- Added Label DTO with default field and color utility methods (hexColor, isLightColor)
- Implemented RepositoryLabelManager for repository-level label operations
- Implemented IssueLabelManager for issue-level label operations
- Created LabelBuilder with fluent API and predefined GitHub color presets
- Added sync functionality to RepositoryLabelManager for batch operations
- Created all required Saloon Request classes for both repository and issue label operations
- 100% test coverage with comprehensive unit tests
- PHPStan level max compliance

Closes #23
@coderabbitai
Copy link

coderabbitai bot commented Dec 19, 2025

Warning

Rate limit exceeded

@jordanpartridge has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 6 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between e989aa8 and 5c3d907.

📒 Files selected for processing (18)
  • src/Data/Label.php (3 hunks)
  • src/Requests/IssueLabels/AddIssueLabelsRequest.php (1 hunks)
  • src/Requests/IssueLabels/ClearIssueLabelsRequest.php (1 hunks)
  • src/Requests/IssueLabels/ListIssueLabelsRequest.php (1 hunks)
  • src/Requests/IssueLabels/RemoveIssueLabelRequest.php (1 hunks)
  • src/Requests/IssueLabels/SetIssueLabelsRequest.php (1 hunks)
  • src/Requests/RepositoryLabels/CreateLabelRequest.php (1 hunks)
  • src/Requests/RepositoryLabels/DeleteLabelRequest.php (1 hunks)
  • src/Requests/RepositoryLabels/GetLabelRequest.php (1 hunks)
  • src/Requests/RepositoryLabels/ListLabelsRequest.php (1 hunks)
  • src/Requests/RepositoryLabels/UpdateLabelRequest.php (1 hunks)
  • src/Services/IssueLabelManager.php (1 hunks)
  • src/Services/LabelBuilder.php (1 hunks)
  • src/Services/RepositoryLabelManager.php (1 hunks)
  • tests/Unit/Data/LabelTest.php (3 hunks)
  • tests/Unit/Services/IssueLabelManagerTest.php (1 hunks)
  • tests/Unit/Services/LabelBuilderTest.php (1 hunks)
  • tests/Unit/Services/RepositoryLabelManagerTest.php (1 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/label-api

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Implement Label Management API with Fluent Builder

2 participants