returnnil,errors.New("base branch name cannot be empty")
}
repo:=strings.Split(ctx.Repository,"/")[1]
fmt.Printf("The repository is %v\n",repo)
title:=githubactions.GetInput("title")
iftitle==""{
returnnil,errors.New("title cannot be empty")
}
body:=githubactions.GetInput("body")
assigneesRaw:=githubactions.GetInput("assignees")
assignees:=[]string{}
for_,a:=rangestrings.Split(assigneesRaw,","){
assignees=append(assignees,strings.TrimSpace(a))
}
labelsRaw:=githubactions.GetInput("labels")
labels:=[]string{}
for_,l:=rangestrings.Split(labelsRaw,","){
labels=append(labels,strings.TrimSpace(l))
}
varheadstring
headRaw:=githubactions.GetInput("head")
ifheadRaw==""{
ifos.Getenv("GITHUB_REF_TYPE")!="branch"{
returnnil,fmt.Errorf("set the \"head\" parameter or work from a branch: only branch can create a pull request: %v given as parameter GITHUB_REF_TYPE",githubactions.GetInput("GITHUB_REF_TYPE"))
// createPullRequest takes in the API URL, access token, and configuration for creating a pull request.
// It initializes a Gitea client using the API URL and access token.
// It creates an instance of the Agent struct using the Gitea client.
// It checks if there is an open pull request with the given branch name in the repository using the ExistingOpenPullRequest method of Agent.
// If an open pull request already exists, it returns nil as the pull request and nil error.
// If no open pull request exists, it creates a new pull request using the createPullRequestGitea method of Agent.
// It returns the created pull request and nil error if successful.
// If there is an error while checking for existing pull requests or creating a new pull request, it returns nil as the pull request and the error.
// The function takes in the following parameters:
// - apiUrl: The URL of the Gitea API.
// - token: The access token for authenticating with the Gitea API.
// - config: The configuration for creating the pull request, including the organization, repository, branch details, title, body, assignees, and labels.
// It returns a pointer to the created pull request and an error.