Gitea icon

Gitea

Interact with Gitea via API

Actions393

Overview

This node operation allows you to apply a diff patch to a file in a Git repository hosted on a Gitea server. It is useful for automating updates to files by applying changes represented as patches, committing those changes, and optionally creating new branches. Typical use cases include programmatically updating configuration files, code snippets, or documentation within a repository without manual intervention.

For example, you might use this node to:

  • Apply a patch generated from a code review tool to a repository branch.
  • Automate the process of updating version numbers or changelogs by applying patches.
  • Create a new branch with specific changes applied for testing or feature development.

Properties

Name Meaning
Owner The owner (user or organization) of the repository where the patch will be applied.
Repo The name of the repository to which the patch will be applied.
Author JSON object representing the identity of the author of the commit (e.g., name, email).
Branch Optional branch name to base the patch application on. If not provided, the repository's default branch is used.
Committer JSON object representing the identity of the committer of the commit (e.g., name, email).
Content The patch content encoded in base64 format. This represents the diff patch to apply.
Dates JSON object specifying commit date options, such as GIT_AUTHOR_DATE and GIT_COMMITTER_DATE.
From Path Optional original file path if the patch involves moving or renaming a file.
Message Optional commit message describing the patch application. If omitted, a default message will be used.
New Branch Optional name of a new branch to create from the specified branch before applying the patch.
Sha The SHA hash of the existing file that the patch will modify. This ensures the patch applies to the correct file version.
Signoff Boolean flag indicating whether to add a "Signed-off-by" trailer by the committer at the end of the commit message. Defaults to true.

Output

The node outputs JSON data representing the result of the patch application operation. This typically includes information about the commit created by applying the patch, such as commit SHA, URL, and metadata about the updated file(s).

If binary data is output, it would generally represent file contents or related artifacts, but this operation primarily deals with JSON responses from the API reflecting commit and repository state.

Dependencies

  • Requires access to a Gitea instance via its REST API.
  • Needs an API authentication token or key configured in n8n credentials to authorize requests.
  • The node depends on the Gitea API endpoint /api/v1 and expects the base URL to be set accordingly.
  • Input patch content must be base64 encoded before being passed to the node.

Troubleshooting

  • Invalid SHA error: Occurs if the provided SHA does not match the current file version. Ensure the SHA corresponds to the latest commit of the target file.
  • Authentication failures: Verify that the API key or token has sufficient permissions to write to the repository.
  • Branch not found: If specifying a branch, confirm it exists or provide a valid branch name.
  • Malformed patch content: The patch must be correctly formatted and base64 encoded; otherwise, the API will reject it.
  • Permission denied errors: Check user permissions on the repository, especially when creating new branches or committing changes.
  • Missing required properties: Ensure all required fields like Owner, Repo, Content, and Sha are provided.

Links and References

Discussion