Skip to content

Implement SearchCommits API functionality for issue #145 - #284

Open
konard wants to merge 3 commits into
mainfrom
issue-145-ed6e2131
Open

Implement SearchCommits API functionality for issue #145#284
konard wants to merge 3 commits into
mainfrom
issue-145-ed6e2131

Conversation

@konard

@konard konard commented Sep 12, 2025

Copy link
Copy Markdown
Member

🎯 Overview

This pull request implements the SearchCommits API functionality requested in issue #145. Since the Octokit.NET library does not yet support SearchCommits (as referenced in the closed Octokit.NET issue #2425), this implementation provides the functionality through direct GitHub API calls.

🔍 Issue Analysis

🚀 Implementation Details

1. Octokit.NET Upgrade

  • Updated from version 7.0.1 to 14.0.0 (latest as of January 2024)
  • Fixed breaking changes where ID types changed from int to long

2. SearchCommits Method

Added to GitHubStorage class:

public async Task<SearchCommitsResult> SearchCommits(string query)

Features:

  • Direct HTTP calls to GitHub's /search/commits endpoint
  • Proper authentication handling (Bearer/Basic tokens)
  • Comprehensive error handling and response validation
  • Full deserialization of GitHub API response structure

3. Data Models

Created complete data model hierarchy:

  • SearchCommitsResult - Main container with TotalCount and Items
  • CommitSearchResult - Individual commit information
  • Supporting models for Author, Committer, Repository, Tree, Parents

4. Usage Examples

// Search commits in specific repository
var results = await githubStorage.SearchCommits("repo:linksplatform/Bot");

// Search by author
var results = await githubStorage.SearchCommits("repo:linksplatform/Bot author:FreePhoenix888");

// Search by message content
var results = await githubStorage.SearchCommits("repo:linksplatform/Bot upgrade framework");

// Search with date range
var results = await githubStorage.SearchCommits("repo:linksplatform/Bot author-date:>=2024-01-01");

📋 Files Changed

  1. csharp/Platform.Bot/Platform.Bot.csproj - Octokit version upgrade
  2. csharp/Storage/Storage.csproj - Octokit version upgrade
  3. csharp/Storage/RemoteStorage/GitHubStorage.cs - SearchCommits implementation + data models
  4. examples/search-commits-example.cs - Working example with documentation
  5. examples/search-commits-example.csproj - Example project configuration

✅ Testing

  • ✅ Successfully builds with .NET 8
  • ✅ Updated Octokit version and resolved breaking changes
  • ✅ Example project runs and demonstrates usage
  • ✅ All existing functionality preserved

🔮 Future Considerations

This implementation provides immediate functionality while waiting for official Octokit.NET support. When SearchCommits is eventually added to Octokit.NET, the implementation can be easily updated to use the official API while maintaining the same method signature and return types.

🎉 Solution Summary

Issue #145 is now resolved

  • SearchCommits functionality is available and ready to use
  • Comprehensive implementation with examples
  • Maintains compatibility with existing codebase
  • Proper documentation and error handling

This implementation bridges the gap until Octokit.NET officially adds SearchCommits support.


Resolves #145

Adding CLAUDE.md with task information for AI processing.
This file will be removed when the task is complete.

Issue: #145
@konard konard self-assigned this Sep 12, 2025
This commit addresses issue #145 by implementing the SearchCommits functionality that was requested to be used when it becomes available in the Octokit library.

## Changes Made:

### 1. Upgrade Octokit.NET
- Updated from version 7.0.1 to 14.0.0 (latest)
- Fixed breaking changes (ID types changed from int to long)

### 2. SearchCommits Implementation
- Added SearchCommits method to GitHubStorage class
- Implemented direct HTTP API calls to GitHub's /search/commits endpoint
- Created comprehensive data models matching GitHub API response structure
- Added proper authentication support for Bearer and Basic tokens

### 3. Data Models Added:
- SearchCommitsResult: Main result container
- CommitSearchResult: Individual commit result
- CommitSearchCommit, CommitSearchAuthor, CommitSearchTree: Supporting structures
- CommitSearchRepository, CommitSearchOwner: Repository information

### 4. Example and Documentation
- Created working example in examples/search-commits-example.cs
- Added comprehensive documentation and usage scenarios
- Demonstrates various search patterns (by repo, author, message, date range)

## Background:
- Issue #145 references Octokit.NET issue #2425 which was closed as stale
- SearchCommits API is available in GitHub REST API but not yet in Octokit.NET
- This implementation provides immediate functionality while waiting for official support

## Usage:
```csharp
var githubStorage = new GitHubStorage(username, token, appName);
var results = await githubStorage.SearchCommits("repo:owner/repo author:username");
```

The implementation bridges the gap until Octokit.NET officially adds SearchCommits support.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@konard konard changed the title [WIP] Use api when it will be added to octokit library Implement SearchCommits API functionality for issue #145 Sep 12, 2025
@konard
konard marked this pull request as ready for review September 12, 2025 20:07
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.

Use SearchCommits api when it will be added to octokit library

1 participant