Skip to content

Refactor gitstatus.go to use go-github package#5

Merged
DMcP89 merged 4 commits intomainfrom
copilot/fix-4
Sep 4, 2025
Merged

Refactor gitstatus.go to use go-github package#5
DMcP89 merged 4 commits intomainfrom
copilot/fix-4

Conversation

Copy link
Contributor

Copilot AI commented Sep 2, 2025

This PR refactors the internal/apis/gitstatus.go file to use the official go-github package instead of custom HTTP handling and struct definitions.

Changes Made

Replaced Custom Implementation:

  • Removed 89 lines of custom struct definitions (Actor, Repo, Author, Commit, Payload, Event)
  • Replaced manual HTTP requests with go-github client methods
  • Added OAuth2 token authentication for secure API access

Updated Functions:

  • GetGitHubUser() - Now uses client.Users.Get()
  • GetGitHubEvents() - Now uses client.Activity.ListEventsPerformedByUser()
  • GetGitHubCommits() - Updated to work with go-github event structures

Enhanced Error Handling:

  • Added proper nil-safety checks for all pointer fields
  • Improved error messages and handling
  • Maintained identical output format for backward compatibility

Dependencies Added

  • github.com/google/go-github/v57 v57.0.0 - Official GitHub API client
  • golang.org/x/oauth2 v0.30.0 - OAuth2 authentication

Testing

  • All existing tests updated and passing (4/4 GitHub-related tests)
  • Added comprehensive test coverage for edge cases
  • Verified output format remains exactly the same
  • Build system works correctly with new dependencies

The refactoring reduces code complexity while leveraging a robust, well-maintained library for GitHub API interactions.

Fixes #4.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • icanhazdadjoke.com
    • Triggering command: /tmp/go-build4182161886/b375/apis.test -test.testlogfile=/tmp/go-build4182161886/b375/testlog.txt -test.paniconexit0 -test.timeout=10m0s (dns block)
    • Triggering command: /tmp/go-build4041625317/b001/apis.test -test.testlogfile=/tmp/go-build4041625317/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build1478738131/b379/apis.test -test.testlogfile=/tmp/go-build1478738131/b379/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link
Contributor Author

Copilot AI commented Sep 2, 2025

@DMcP89 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI and others added 2 commits September 2, 2025 16:33
Co-authored-by: DMcP89 <4146149+DMcP89@users.noreply.github.com>
Co-authored-by: DMcP89 <4146149+DMcP89@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor gitstatus.go to use go-github package Refactor gitstatus.go to use go-github package Sep 2, 2025
Copilot AI requested a review from DMcP89 September 2, 2025 16:37
@DMcP89 DMcP89 marked this pull request as ready for review September 4, 2025 01:21
@DMcP89 DMcP89 merged commit de59c2b into main Sep 4, 2025
1 of 2 checks passed
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.

Refactor gitstatus.go to use go-github package

2 participants