Skip to content

Implement repository information fetching infrastructure#3

Merged
Malcolmnixon merged 5 commits intomainfrom
copilot/fetch-repository-information
Jan 29, 2026
Merged

Implement repository information fetching infrastructure#3
Malcolmnixon merged 5 commits intomainfrom
copilot/fetch-repository-information

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 29, 2026

Pull Request

Description

Implements a provider-agnostic interface for fetching repository metadata (tags, pull requests, issues, git hashes) required for build note generation. Initial implementation supports GitHub via git and gh CLI tools.

Core Components

  • IRepoConnector - Interface defining repository operations (tag history, PR/issue retrieval, git hashes)
  • RepoConnectorBase - Base class with virtual RunCommandAsync for testable CLI execution
  • GitHubRepoConnector - GitHub implementation with regex-based input validation to prevent command injection
  • MockRepoConnector - Deterministic mock for downstream testing (includes beta and rc versions)
  • RepoConnectorFactory - Auto-detects repository provider from environment variables or git remote URL
  • ProcessRunner - Common helper class for running external processes and capturing output

Security

All user inputs (tag names, issue/PR IDs) validated against allowlist patterns before CLI invocation:

  • Tag names: ^[a-zA-Z0-9._/-]+$
  • Issue/PR IDs: ^\d+$

Example Usage

// Factory auto-detects GitHub
var connector = RepoConnectorFactory.Create();

// Get tags in chronological order (includes beta/rc versions)
var tags = await connector.GetTagHistoryAsync();

// Get PRs between releases
var prs = await connector.GetPullRequestsBetweenTagsAsync("v1.0.0", "v2.0.0");

// Get issues linked to PR
var issues = await connector.GetIssuesForPullRequestAsync("123");

// For testing, use mock with deterministic data
var mock = new MockRepoConnector();

Type of Change

  • New feature (non-breaking change which adds functionality)

Related Issues

Pre-Submission Checklist

Build and Test

  • Code builds successfully: dotnet build --configuration Release
  • All tests pass: dotnet test --configuration Release
  • Code produces zero warnings

Code Quality

  • Code formatting is correct: dotnet format --verify-no-changes
  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

  • Spell checker passes: cspell "**/*.{md,cs}"
  • Markdown linter passes: markdownlint "**/*.md"
  • YAML linter passes: yamllint '**/*.{yml,yaml}'

Testing

  • Added unit tests for new functionality
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated ARCHITECTURE.md (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

  • 35 unit tests covering all functionality including security validation
  • Zero CodeQL vulnerabilities detected
  • Classes organized in RepoConnectors/ subfolder for maintainability
  • Assumes git and gh CLI tools are installed on system
  • ProcessRunner eliminates code duplication for process execution across RepoConnectorBase and RepoConnectorFactory
  • MockRepoConnector includes pre-release versions (v2.0.0-beta.1, v2.0.0-rc.1) to support different build-note generation paths
Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: Fetch Repository Information</issue_title>
<issue_description>### Problem Statement

Build Notes requires mining information from the repository including tags, pull-requests, issues, and git hashes.

Proposed Solution

Getting repository information is provider-specific. Currently the intent is to support GitHub, but Azure DevOps and other providers may be supported later. As such a generic IRepoConnector interface should be defined, and then a GitHub implementation created.

The classes will work with the repository the tool is executing under.

The operations required include:

  • Getting the history of tags leading to the current branch
  • Get the list of pull request IDs between two tags in the repository (from/to) with either one being blank/null to indicate the start/end of the history
  • Get the issue IDs associated with a pull request
  • Get an issues title and type (bug, feature, etc.)
  • Get a hash for a git tag (with blank/null being the hash of the current repo state)

It would also be beneficial to have a RepoConnectorFactory static class that creates IRepoConnector instances based on determining the type of repository used - possibly by checking for environment variables expected under CI build agents, or by inspecting the origin of the repo.

While the IRepoConnector interface allows for testing down-stream consumers (via dependency injection) a means will also need to exist to test the implementations. One approach may be that all RepoConnector instances have a common base class, and that common base has an overridable Run method which it uses to run CLI commands (git or gh). Then testing would entail overriding that method to inject fake results and ensuring the result-processing works.

Finally a MockRepoConnector may want to be created that produces deterministic output - required for eventual self-validation.

Alternatives Considered

No response

Usage Examples

Benefits

Ability to read repository information.

Priority

High - Blocking my use case

Willingness to Contribute

Yes, I can submit a pull request

Additional Context

It seems almost everything required for the GitHub implementation can be achieved using combinations of the 'git' and 'gh' commands. The implementation can assume both of these tools are installed on the system.

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided a clear description of the feature
  • I have explained why this feature would be useful</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 29, 2026 15:35
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Copilot AI changed the title [WIP] Add feature to fetch repository information Implement repository information fetching infrastructure Jan 29, 2026
Copilot AI requested a review from Malcolmnixon January 29, 2026 15:48
… mock

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
@Malcolmnixon Malcolmnixon marked this pull request as ready for review January 29, 2026 16:12
@Malcolmnixon Malcolmnixon merged commit ca0f78b into main Jan 29, 2026
10 checks passed
@Malcolmnixon Malcolmnixon deleted the copilot/fetch-repository-information branch January 29, 2026 16:14
Copilot AI mentioned this pull request Feb 6, 2026
21 tasks
Copilot AI added a commit that referenced this pull request Feb 6, 2026
- Add BuildMark_MarkdownReportGeneration test
- Add BuildMark_GitIntegration test
- Add BuildMark_IssueTracking test
- Add BuildMark_KnownIssuesReporting test
- Tests check for GitHub token and skip gracefully if not available
- These tests satisfy requirements GH-1, GH-2, GH-3, RPT-001-009, PLT-001-005
- Tests run BuildMark on itself for self-validation
Malcolmnixon added a commit that referenced this pull request Feb 7, 2026
* Initial plan

* Add self-validation integration tests for requirements traceability

- Add BuildMark_MarkdownReportGeneration test
- Add BuildMark_GitIntegration test
- Add BuildMark_IssueTracking test
- Add BuildMark_KnownIssuesReporting test
- Tests check for GitHub token and skip gracefully if not available
- These tests satisfy requirements GH-1, GH-2, GH-3, RPT-001-009, PLT-001-005
- Tests run BuildMark on itself for self-validation

* Refactor: Extract GitHub token check to helper method

- Add SkipIfNoGitHubToken() helper to reduce code duplication
- All four self-validation tests now use the shared helper
- Addresses code review feedback

* docs: Fix spell checking issues

- Add 'buildnotes' to cspell dictionary for docs/buildnotes/definition.yaml
- Add 'myterm' as valid example term used in CONTRIBUTING.md
- Add test-results directory to cspell ignore paths to exclude generated files

* feat: Add internal constructor to GitHubGraphQLClient for testability

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>

* test: Add unit tests for GitHubGraphQLClient with mocked HttpClient

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>

* refactor: Remove conditional skip logic from BuildMark self-validation tests

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>

* Remove duplicate BuildMark_* tests from IntegrationTests.cs

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
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.

[Feature]: Fetch Repository Information

2 participants