Merge pull request #1780 from bobrik/bitbucket-cleanup

Cleanup debug logging in Bitbucket Server remote
This commit is contained in:
Brad Rydzewski 2016-09-01 11:58:44 -05:00 committed by GitHub
commit d4db122c3d
2 changed files with 11 additions and 22 deletions

View file

@ -4,15 +4,14 @@ import (
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
log "github.com/Sirupsen/logrus"
"github.com/drone/drone/model"
"github.com/drone/drone/remote/bitbucketserver/internal"
"github.com/mrjones/oauth"
"net/url" "net/url"
"strings" "strings"
"time" "time"
)
"github.com/drone/drone/model"
"github.com/drone/drone/remote/bitbucketserver/internal"
"github.com/mrjones/oauth"
)
const ( const (
statusPending = "INPROGRESS" statusPending = "INPROGRESS"
@ -83,7 +82,6 @@ func convertRepo(from *internal.Repo) *model.Repo {
repo.Link = item.Href repo.Link = item.Href
} }
} }
log.Debug(fmt.Printf("Repo: %+v\n", repo))
return &repo return &repo
} }
@ -152,6 +150,5 @@ func avatarLink(email string) string {
hasher.Write([]byte(strings.ToLower(email))) hasher.Write([]byte(strings.ToLower(email)))
emailHash := fmt.Sprintf("%v", hex.EncodeToString(hasher.Sum(nil))) emailHash := fmt.Sprintf("%v", hex.EncodeToString(hasher.Sum(nil)))
avatarURL := fmt.Sprintf("https://www.gravatar.com/avatar/%s.jpg", emailHash) avatarURL := fmt.Sprintf("https://www.gravatar.com/avatar/%s.jpg", emailHash)
log.Debug(avatarURL)
return avatarURL return avatarURL
} }

View file

@ -4,13 +4,14 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"io/ioutil"
"net/http"
"strconv" "strconv"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"github.com/drone/drone/model" "github.com/drone/drone/model"
"github.com/mrjones/oauth" "github.com/mrjones/oauth"
"io/ioutil"
"net/http"
"io"
) )
const ( const (
@ -35,7 +36,6 @@ func NewClientWithToken(url string, consumer *oauth.Consumer, AccessToken string
var token oauth.AccessToken var token oauth.AccessToken
token.Token = AccessToken token.Token = AccessToken
client, err := consumer.MakeHttpClient(&token) client, err := consumer.MakeHttpClient(&token)
log.Debug(fmt.Printf("Create client: %+v %s\n", token, url))
if err != nil { if err != nil {
log.Error(err) log.Error(err)
} }
@ -109,7 +109,6 @@ func (c *Client) FindRepoPerms(owner string, repo string) (*model.Perm, error) {
perms.Admin = true perms.Admin = true
} }
perms.Pull = true perms.Pull = true
log.Debug(fmt.Printf("Perms: %+v\n", perms))
return perms, nil return perms, nil
} }
@ -160,7 +159,6 @@ func (c *Client) doPut(url string, body []byte) error {
return nil return nil
} }
//Helper function to help create the hook //Helper function to help create the hook
func (c *Client) doPost(url string, status *BuildStatus) error { func (c *Client) doPost(url string, status *BuildStatus) error {
// write it to the body of the request. // write it to the body of the request.
@ -182,10 +180,6 @@ func (c *Client) doPost(url string, status *BuildStatus) error {
return nil return nil
} }
//Helper function to do delete on the hook //Helper function to do delete on the hook
func (c *Client) doDelete(url string) error { func (c *Client) doDelete(url string) error {
request, err := http.NewRequest("DELETE", url, nil) request, err := http.NewRequest("DELETE", url, nil)
@ -201,7 +195,6 @@ func (c *Client) doDelete(url string) error {
func (c *Client) paginatedRepos(start int) ([]*Repo, error) { func (c *Client) paginatedRepos(start int) ([]*Repo, error) {
limit := 1000 limit := 1000
requestUrl := fmt.Sprintf(pathRepos, c.base, strconv.Itoa(start), strconv.Itoa(limit)) requestUrl := fmt.Sprintf(pathRepos, c.base, strconv.Itoa(start), strconv.Itoa(limit))
log.Debugf("request :%s", requestUrl)
response, err := c.client.Get(requestUrl) response, err := c.client.Get(requestUrl)
if err != nil { if err != nil {
return nil, err return nil, err
@ -212,9 +205,8 @@ func (c *Client) paginatedRepos(start int) ([]*Repo, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
log.Debugf("repoResponse: %+v", repoResponse) if !repoResponse.IsLastPage {
if(!repoResponse.IsLastPage){ reposList, err := c.paginatedRepos(start + limit)
reposList, err := c.paginatedRepos(start + limit);
if err != nil { if err != nil {
return nil, err return nil, err
} }