A powerful .NET console application that provides seamless integration with GitHub's API using the Octokit library, offering a beautiful and interactive interface for managing repositories, commits, pull requests, and advanced GitHub operations.
- Test GitHub API connection with personal access token
- Display comprehensive user profile information
- Validate permissions and token validity
- List all accessible repositories (owned + collaborator)
- Show repository metadata (language, stars, forks, privacy status)
- Filter and sort repository information
- View recent commits from any repository
- Display commit details with author information
- Navigate through commit history with pagination
- Retrieve file content from any repository
- Support for different branches
- Display file content in a formatted panel
- List pull requests with state filtering (open, closed, all)
- View detailed pull request information
- Add comments to pull requests
- Create pull request reviews (approve, request changes, comment)
- View repository statistics (contributors, languages, branches, tags)
- Browse repository file structure
- Navigate directories and files with tree view
- Search code across repositories
- Search repositories by query
- Advanced search with filters and operators
- .NET 9.0 SDK or later
- GitHub Personal Access Token
- Git (for cloning the repository)
-
Clone the repository
git clone <repository-url> cd GitHubIntegration
-
Configure environment variables
Copy the example environment file:
cp .env.example .env
Edit
.env
and add your GitHub credentials:GITHUB_TOKEN=ghp_your_personal_access_token_here GITHUB_REPO_OWNER=your_github_username GITHUB_REPO_NAME=your_default_repo_name
-
Install dependencies
dotnet restore
-
Run the application
dotnet run
- Go to GitHub β Settings β Developer settings β Personal access tokens
- Generate a new token with the following scopes:
repo
- Full repository accessread:user
- Read user profileread:org
- Read organization membership (optional)
Variable | Description | Required |
---|---|---|
GITHUB_TOKEN |
Your GitHub Personal Access Token | β |
GITHUB_REPO_OWNER |
Your GitHub username | β |
GITHUB_REPO_NAME |
Default repository name | β |
The application provides an intuitive console interface with submenu navigation:
- π Test Connection & Show User Info - Validate your GitHub connection and display profile
- π List Accessible Repositories - Browse all repositories you have access to
- π List Recent Commits - View recent commits from any repository
- π Get File Content - Retrieve and display file contents
- π§Ύ Commit Details - View detailed commit information
- π List Pull Requests - View pull requests with filtering
- π Get Pull Request Details - View detailed PR information
- π Repository Statistics - View repository analytics
- π§ PR Management - Add comments and create reviews
- π Search & Discovery - Search code and repositories
- π Repository Browser - Browse file structure
- β Exit - Close the application
- PR Management: Add PR comments, Create PR reviews
- Search & Discovery: Code search, Repository search
- Repository Browser: Browse repository structure
π Test Connection & Show User Info
β
Connection successful!
βββββββββββββββ¬ββββββββββββββββββ
β Property β Value β
βββββββββββββββΌββββββββββββββββββ€
β Username β your-username β
β Name β Your Full Name β
β Email β your@email.com β
β Location β Your City β
β Public Reposβ 25 β
β Followers β 150 β
β Following β 75 β
β Created β 2020-01-15 β
βββββββββββββββ΄ββββββββββββββββββ
π Found 15 repositories:
βββββββββββββββββββββββ¬βββββββββββ¬βββββββ¬βββββββ¬ββββββββββ¬βββββββββββββ
β Name β Language β Starsβ Forksβ Private β Updated β
βββββββββββββββββββββββΌβββββββββββΌβββββββΌβββββββΌββββββββββΌβββββββββββββ€
β your-username/repo1 β C# β 45 β 12 β π β 2024-01-15 β
β your-username/repo2 β Python β 23 β 8 β π β 2024-01-10 β
βββββββββββββββββββββββ΄βββββββββββ΄βββββββ΄βββββββ΄ββββββββββ΄βββββββββββββ
GitHubIntegration/
βββ Models/
β βββ GitHubSettings.cs # Configuration model
β βββ RepositoryStatistics.cs # Repository statistics model
βββ Services/
β βββ IGitHubService.cs # GitHub service interface
β βββ GitHubService.cs # GitHub API implementation using Octokit
β βββ ConsoleUIService.cs # Console UI and interactions
β βββ ConfigurationService.cs # Configuration management
βββ Program.cs # Application entry point
βββ GitHubIntegration.csproj # Project configuration
- GitHubService: Handles all GitHub API interactions using Octokit
- ConsoleUIService: Manages the beautiful console interface using Spectre.Console
- ConfigurationService: Loads and validates environment variables
- Dependency Injection: Properly configured services for testability
dotnet build
dotnet test
The project follows C# coding conventions and uses nullable reference types.
- Octokit: Official GitHub API client library for .NET
- Spectre.Console: Beautiful console UI components
- Microsoft.Extensions.Configuration: Configuration management
- Microsoft.Extensions.DependencyInjection: Dependency injection container
- Microsoft.Extensions.Logging: Structured logging
- DotNetEnv: Environment variable loading from .env files
- Repository browsing and navigation
- Advanced PR operations
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
"GITHUB_TOKEN environment variable is required"
- Ensure your
.env
file exists and contains the correct token - Verify the token has the required scopes
"Connection failed"
- Check your internet connection
- Verify your GitHub token is valid and not expired
- Ensure the token has the correct permissions
"Repository not found"
- Verify the repository owner and name are correct
- Ensure you have access to the repository
- Check if the repository is private and your token has access
For issues and questions:
- Check the troubleshooting section above
- Review GitHub API documentation
- Open an issue in the repository
Happy coding! π