Fix against new git interfaces
This commit is contained in:
parent
a84d55c858
commit
d46ca05346
@ -45,6 +45,7 @@ type GitStatusLister interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Git interface {
|
type Git interface {
|
||||||
|
GitCatFile(cwd, commitId, filename string) (data []byte, err error)
|
||||||
GetPath() string
|
GetPath() string
|
||||||
|
|
||||||
CloneDevel(gitDir, outName, urlString string) error
|
CloneDevel(gitDir, outName, urlString string) error
|
||||||
|
@ -55,9 +55,9 @@ func failOnError(err error, msg string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchPrGit(git *common.GitHandler, pr *models.PullRequest) error {
|
func fetchPrGit(git common.Git, pr *models.PullRequest) error {
|
||||||
// clone PR head and base and return path
|
// clone PR head and base and return path
|
||||||
if _, err := os.Stat(path.Join(git.GitPath, pr.Head.Sha)); os.IsNotExist(err) {
|
if _, err := os.Stat(path.Join(git.GetPath(), pr.Head.Sha)); os.IsNotExist(err) {
|
||||||
git.GitExec("", "clone", "--depth", "1", pr.Head.Repo.CloneURL, pr.Head.Sha)
|
git.GitExec("", "clone", "--depth", "1", pr.Head.Repo.CloneURL, pr.Head.Sha)
|
||||||
git.GitExec(pr.Head.Sha, "fetch", "--depth", "1", "origin", pr.Head.Sha, pr.Base.Sha)
|
git.GitExec(pr.Head.Sha, "fetch", "--depth", "1", "origin", pr.Head.Sha, pr.Base.Sha)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
@ -234,7 +234,7 @@ func processRepoBuildStatus(results, ref []common.PackageBuildStatus) BuildStatu
|
|||||||
return BuildStatusSummarySuccess
|
return BuildStatusSummarySuccess
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateObsPrjMeta(git *common.GitHandler, gitea common.Gitea, pr *models.PullRequest, obsClient *common.ObsClient) (*common.ProjectMeta, error) {
|
func generateObsPrjMeta(git common.Git, gitea common.Gitea, pr *models.PullRequest, obsClient *common.ObsClient) (*common.ProjectMeta, error) {
|
||||||
log.Println("repo content fetching ...")
|
log.Println("repo content fetching ...")
|
||||||
err := fetchPrGit(git, pr)
|
err := fetchPrGit(git, pr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -312,7 +312,7 @@ func generateObsPrjMeta(git *common.GitHandler, gitea common.Gitea, pr *models.P
|
|||||||
return meta, nil
|
return meta, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func startOrUpdateBuild(git *common.GitHandler, gitea common.Gitea, pr *models.PullRequest, obsClient *common.ObsClient) error {
|
func startOrUpdateBuild(git common.Git, gitea common.Gitea, pr *models.PullRequest, obsClient *common.ObsClient) error {
|
||||||
log.Println("fetching OBS project Meta")
|
log.Println("fetching OBS project Meta")
|
||||||
obsPrProject := getObsProjectAssociatedWithPr(obsClient.HomeProject, pr)
|
obsPrProject := getObsProjectAssociatedWithPr(obsClient.HomeProject, pr)
|
||||||
meta, err := obsClient.GetProjectMeta(obsPrProject)
|
meta, err := obsClient.GetProjectMeta(obsPrProject)
|
||||||
@ -362,7 +362,7 @@ func processPullNotification(gitea common.Gitea, thread *models.NotificationThre
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
gh := common.GitHandlerImpl{}
|
gh := common.GitHandlerGeneratorImpl{}
|
||||||
git, err := gh.CreateGitHandler(GitAuthor, "noaddress@suse.de", BotName)
|
git, err := gh.CreateGitHandler(GitAuthor, "noaddress@suse.de", BotName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicln(err)
|
log.Panicln(err)
|
||||||
@ -384,11 +384,16 @@ func processPullNotification(gitea common.Gitea, thread *models.NotificationThre
|
|||||||
repo := match[2]
|
repo := match[2]
|
||||||
id, _ := strconv.ParseInt(match[3], 10, 64)
|
id, _ := strconv.ParseInt(match[3], 10, 64)
|
||||||
|
|
||||||
pr, reviews, err := gitea.GetPullRequestAndReviews(org, repo, id)
|
pr, err := gitea.GetPullRequest(org, repo, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("No PR associated with review:", notification.URL, "Error:", err)
|
log.Println("No PR associated with review:", notification.URL, "Error:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
reviews, err := gitea.GetPullRequestReviews(org, repo, id)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("No reviews associated with request:", notification.URL, "Error:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
obsClient, err := common.NewObsClient("api.opensuse.org")
|
obsClient, err := common.NewObsClient("api.opensuse.org")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user