Skip to content

Commit

Permalink
fix diffpatch uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotoNomad0 committed Sep 13, 2023
1 parent 9ac17ed commit 652eb71
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
3 changes: 3 additions & 0 deletions src/components/file/useEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -23,6 +24,7 @@ export default function useEdit({
config,
branch,
author,
email,
content,
message,
filepath,
Expand Down Expand Up @@ -100,6 +102,7 @@ export default function useEdit({
owner,
config,
author,
email,
content,
filepath,
message: _message,
Expand Down
20 changes: 15 additions & 5 deletions src/core/gitea-api/repos/contents/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ModifyContentOptions {
content?: string;
message: string;
author: Author;
email?: string;
sha?: string;
onOpenValidation?: (filename: string, content: string, url: string) => never;
};
Expand Down Expand Up @@ -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<ContentObject> => {
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,
}
Expand Down

0 comments on commit 652eb71

Please sign in to comment.