Class StatusToGithub

java.lang.Object
com.group8.StatusToGithub

public class StatusToGithub extends Object
Client for interacting with the GitHub Commit Status API (P3).

It reads a personal access token from the GH_TOKEN environment variable and exposes convenience methods to get and set the status of a commit in a given repository.

  • Constructor Details

    • StatusToGithub

      public StatusToGithub(String owner, String repo)
      Creates a status client for the given repository using the default HttpClientWrapper implementation.
      Parameters:
      owner - repository owner (user or organisation)
      repo - repository name
  • Method Details

    • getCommitStatus

      public String getCommitStatus(String sha)
      Retrieves commit status from GitHub for the given SHA.
      Parameters:
      sha - Git commit SHA to look up
      Returns:
      one of "success", "failure" or "pending" depending on the latest combined status; returns "failure" if an exception occurs
    • setCommitStatus

      public boolean setCommitStatus(String sha, String state)
      Sets the commit status for the given SHA.
      Parameters:
      sha - Git commit SHA to annotate
      state - desired status ("error", "failure", "pending" or "success")
      Returns:
      true if GitHub accepted the status (HTTP 201), false otherwise or when the state is invalid
    • main

      public static void main(String[] args)