Connect to Gitea API #14
Loading…
Reference in New Issue
No description provided.
Delete Branch "a34sun/connect-to-gitea-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Function that creates new PR
Nice work!! Left some quick comments. Also, you should assign as as 'Reviewers" not assignees on gitea :)
@ -9,0 +4,4 @@
export const MAIN_BRANCH = "main"
export const GITEA_API_URL = "https://git.csclub.uwaterloo.ca/api/v1/repos"
export const makePullRequest = async (owner: string, repoName: string, title: string, body:string, branchName: string, assignee: string) => {
Nice work! Instead of assignee, we should use reviwers. So please add "reviewers: Array" as a paramater. To add reviewers, it seems like we need to make another API call, here is a starting point I got from playing around. Note that you can get the PR number by calling
content.number
from the PR response:Furthermore, lets make the assignee param optional by adding a default empty string:
@ -9,0 +6,4 @@
export const makePullRequest = async (owner: string, repoName: string, title: string, body:string, branchName: string, assignee: string) => {
const PULL_URL = `${GITEA_API_URL}/${owner}/${repoName}/pulls`
console.log(PULL_URL)
You can delete this log, doesn't really add much value IMO to stick around long term.
@ -9,0 +23,4 @@
head: branchName,
})
});
const content = await response.json();
Here, lets check whether the call succeeded or not, and throw an error if it didn't, and return the pr url if it did:
@ -84,3 +84,2 @@
// TODO: Remove this, only for demo purposes
makePullRequest();
// TODO: Implement this for www
You can just delete these lines.
Right now the function returns the PR is successful but doesn't know if add reviewers was successful, is this how it should work?
LGTM! Yep, what you had was fine,
I just did add
await addReviewers(reviewers, owner, repoName, content.number);
an "await"so that it does wait for the add reviews to finish.