Skip to content

Add author and committer support to content create/update/delete APIs #2199

@pvillard31

Description

@pvillard31

The GitHub REST API for creating, updating, and deleting file contents supports optional author and committer parameters that allow callers to specify a different author or committer than the authenticated user:

  • PUT /repos/{owner}/{repo}/contents/{path} (create/update)
  • DELETE /repos/{owner}/{repo}/contents/{path} (delete)

Both parameters are JSON objects with name (required), email (required), and date (optional) fields. When provided, the resulting Git commit records the specified person as the author or committer, enabling the standard Git distinction between "author" (who wrote the change) and "committer" (who applied it). GitHub's UI renders this as "UserX authored and ServiceAccount committed".

API reference: https://docs.github.com/en/rest/repos/contents#create-or-update-file-contents

Current behavior

  • GHContentBuilder (used via GHRepository.createContent()) does not expose methods to set author or committer.
  • GHContent.update() and GHContent.delete() build their requests without support for these parameters.

Requested changes

  1. Add author(String name, String email) and committer(String name, String email) methods to GHContentBuilder, with optional overloads accepting an Instant date parameter.

  2. Add builder-style APIs for update and delete (GHContentUpdater and GHContentDeleter, accessible via GHContent.createUpdate() and GHContent.createDelete()) that support author, committer, branch, content, and message configuration.

Use case

Applications that use a single service account (PAT or GitHub App) to manage files in a repository on behalf of multiple end-users need to attribute each commit to the specific end-user who initiated the action, while the service account remains the committer. The GitHub REST API supports this natively, but the library does not currently expose it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions