harness-drone/trigger/change.go

65 lines
1.8 KiB
Go
Raw Normal View History

2019-02-19 23:56:41 +00:00
// Copyright 2019 Drone.IO Inc. All rights reserved.
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
2019-02-28 07:07:13 +00:00
// +build !oss
2019-02-19 23:56:41 +00:00
package trigger
// import (
// "context"
// "regexp"
// "strconv"
// "github.com/drone/drone/core"
// "github.com/drone/go-scm/scm"
// )
// func listChanges(client *scm.Client, repo *core.Repository, build *core.Build) ([]string, error) {
// switch build.Event {
// case core.EventPullRequest:
// return listChangesPullRequest(client, repo, build)
// case core.EventPush:
// return listChangesPush(client, repo, build)
// default:
// return nil, nil
// }
// }
// func listChangesPullRequest(client *scm.Client, repo *core.Repository, build *core.Build) ([]string, error) {
// var paths []string
// pr, err := parsePullRequest(build.Ref)
// if err != nil {
// return nil, err
// }
// change, _, err := client.PullRequests.ListChanges(context.Background(), repo.Slug, pr, scm.ListOptions{})
// if err == nil {
// for _, file := range change {
// paths = append(paths, file.Path)
// }
// }
// return paths, err
// }
// func listChangesPush(client *scm.Client, repo *core.Repository, build *core.Build) ([]string, error) {
// var paths []string
// // TODO (bradrydzewski) some tag hooks provide the tag but do
// // not provide the sha, in which case we should use the ref
// // instead of the sha.
// change, _, err := client.Git.ListChanges(context.Background(), repo.Slug, build.After, scm.ListOptions{})
// if err == nil {
// for _, file := range change {
// paths = append(paths, file.Path)
// }
// }
// return paths, err
// }
// func parsePullRequest(ref string) (int, error) {
// return strconv.Atoi(
// pre.FindString(ref),
// )
// }
// var pre = regexp.MustCompile("\\d+")