Exemple #1
0
func TriggerBuildRepositoryById(rid int64) (err error) {
	repo, err := models.GetRepositoryById(rid)
	if err != nil {
		log.Errorf("get repo by id error: %v", err)
		return
	}
	cvsinfo, _ := base.ParseCvsURI(repo.Uri)
	defaultBranch := "master"
	if cvsinfo.Provider == base.PVD_GOOGLE {
		defaultBranch = ""
	}
	models.CreateNewBuilding(rid, defaultBranch, "", "", models.AC_SRCPKG)
	if !repo.IsCmd {
		return nil
	}
	oas := map[string][]string{
		"windows": []string{"386", "amd64"},
		"linux":   []string{"386", "amd64"},
		"darwin":  []string{"amd64"},
	}
	if repo.IsCgo {
		delete(oas, "windows")
		oas["linux"] = []string{"amd64"}
	}
	for os, archs := range oas {
		for _, arch := range archs {
			err := models.CreateNewBuilding(rid, defaultBranch, os, arch, models.AC_BUILD)
			if err != nil {
				log.Errorf("create module error: %v", err)
			}
		}
	}
	return nil
}
Exemple #2
0
func AddRepository(repoName string) (r *Repository, err error) {
	cvsinfo, err := base.ParseCvsURI(repoName) // base.SanitizedRepoPath(rf.Name)
	if err != nil {
		log.Errorf("parse cvs url error: %v", err)
		return
	}

	repoUri := cvsinfo.FullPath
	r = new(Repository)
	r.Uri = repoUri

	pkginfo, err := gowalker.GetPkgInfo(repoUri)
	if err != nil {
		log.Errorf("gowalker not passed check: %v", err)
		return
	}
	r.IsCgo = pkginfo.IsCgo
	r.IsCmd = pkginfo.IsCmd
	r.Tags = strings.Split(pkginfo.Tags, "|||")
	// description
	r.Brief = pkginfo.Description
	base.ParseCvsURI(repoUri)
	if strings.HasPrefix(repoUri, "github.com") {
		// comunicate with github
		fields := strings.Split(repoUri, "/")
		owner, repoName := fields[1], fields[2]
		repo, _, err := GHClient.Repositories.Get(owner, repoName)
		if err != nil {
			log.Errorf("get information from github error: %v", err)
		} else {
			r.Brief = *repo.Description
		}
	}
	if _, err = CreateRepository(r); err != nil {
		log.Errorf("create repo error: %v", err)
		return
	}
	return r, nil
}
Exemple #3
0
func CreateNewBuilding(rid int64, branch string, os, arch string, action string) (err error) {
	repo, err := GetRepositoryById(rid)
	if err != nil {
		return
	}
	task := &Task{
		Rid:       rid,
		Action:    action,
		TagBranch: branch,
		PushType:  "branch",
		PushValue: branch,
		Os:        os,
		Arch:      arch,
		CgoEnable: repo.IsCgo,
	}
	var cvsinfo *base.CVSInfo
	log.Infof("add task for repo: %v", repo.Uri)
	if cvsinfo, err = base.ParseCvsURI(repo.Uri); err != nil {
		return
	}
	if cvsinfo.Provider == base.PVD_GITHUB {
		info, _, er := GHClient.Repositories.GetBranch(cvsinfo.Owner, cvsinfo.RepoName, branch)
		if er != nil {
			err = er
			return
		}
		log.Infof("get information from github:%v", info)
		task.PushType = "commit"
		task.PushValue = *info.Commit.SHA
		if info.Commit.Message != nil {
			task.CommitMessage = *info.Commit.Message
		}
	}
	_, err = CreateTask(task)
	return
}
Exemple #4
0
func NewRepo(rf RepoInfoForm, ctx *middleware.Context) {
	ci, _ := base.ParseCvsURI(rf.Name)
	ctx.Redirect(302, "/"+ci.FullPath)
}