diff --git a/package.json b/package.json index 3ae1109..de07406 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitea-react-toolkit", - "version": "2.2.6-beta", + "version": "2.2.6-beta.2", "license": "MIT", "description": "A Gitea API React Toolkit Component Library", "homepage": "https://gitea-react-toolkit.netlify.com/", diff --git a/src/components/file/useEdit.js b/src/components/file/useEdit.js index 5e343eb..2ae33bd 100644 --- a/src/components/file/useEdit.js +++ b/src/components/file/useEdit.js @@ -10,6 +10,7 @@ import { patchContent, updateContent } from '../..'; * @param {object} config - config settings for fetches (timeout, cache, etc.) * @param {string} branch - branch name. * @param {string} author - author of the edit. + * @param {string} email - email of the author. * @param {string} content - Edited/updated content. * @param {string} message - Optional commit message. * @param {string} filePath - file path, file path for the file being edited. @@ -23,6 +24,7 @@ export default function useEdit({ config, branch, author, + email, content, message, filepath, @@ -100,6 +102,7 @@ export default function useEdit({ owner, config, author, + email, content, filepath, message: _message, diff --git a/src/core/gitea-api/repos/contents/contents.ts b/src/core/gitea-api/repos/contents/contents.ts index 55c6dfd..168aeb0 100644 --- a/src/core/gitea-api/repos/contents/contents.ts +++ b/src/core/gitea-api/repos/contents/contents.ts @@ -17,6 +17,7 @@ interface ModifyContentOptions { content?: string; message: string; author: Author; + email?: string; sha?: string; onOpenValidation?: (filename: string, content: string, url: string) => never; }; @@ -116,21 +117,30 @@ export const readContent = async ({ // POST /api/v1/repos/{owner}/{repo}/diffpatch export const patchContent = async ({ - config, owner, repo, branch, filepath, content, message, author, sha, + config, owner, repo, branch, filepath, content, message, author, email, sha, }: ModifyContentOptions): Promise => { const url = Path.join(apiPath, 'repos', owner, repo, 'diffpatch'); let contentObject: ContentObject; + const author_ = { + email: email || '', + name: author, + } + var date = new Date(); + var isoDate = date.toISOString(); try { const _payload = { - author, + author: author_, branch, - committer: author, - content: utf8.encode(content || ''), + committer: author_, + content: content || '', from_path: ".", + dates: { + author: isoDate, + committer: isoDate + }, message, - new_branch: branch, sha, signoff: true, }