Ejemplo n.º 1
0
func show() {
	slug := detectSlug()
	client := travis.NewClient()

	repoResp, _ := client.GetRepository(slug)
	if repoResp == (travis.RepositoryResponse{}) {
		println("Couldn't find repository")
		return
	}

	buildResp, _ := client.GetBuild(repoResp.Repository.LastBuildID)
	if buildResp == (travis.BuildResponse{}) {
		println("Couldn't find build.")
		return
	}

	build := buildResp.Build
	commit := buildResp.Commit

	fmt.Printf(bold("Build #%s: %s\n"), build.Number, strings.Split(commit.Message, "\n")[0])
	printInfo("State", build.State)
	if build.PullRequest {
		printInfo("Type", "pull request")
	} else {
		printInfo("Type", "push")
	}
	printInfo("Branch", commit.Branch)
	printInfo("Compare URL", commit.CompareURL)
	printInfo("Duration", formatDuration(build.Duration))
	printInfo("Started", formatTime(build.StartedAt))
	printInfo("Finished", formatTime(build.FinishedAt))
}
Ejemplo n.º 2
0
func encrypt(str string) {
	client := travis.NewClient()
	key, err := client.GetRepositoryKey(detectSlug())
	if err != nil {
		fmt.Printf("Error retrieving repository key: %+v", err)
		return
	}

	pemData := []byte(key.Key)
	block, _ := pem.Decode(pemData)
	maybePub, err := x509.ParsePKIXPublicKey(block.Bytes)
	pub := maybePub.(*rsa.PublicKey)
	out, err := rsa.EncryptPKCS1v15(rand.Reader, pub, []byte(str))
	outStr := base64.StdEncoding.EncodeToString(out)
	fmt.Printf("secure: %q\n", outStr)
}