Skip to content

Commit 527d178

Browse files
author
jguerreiro
committed
fix(bitbucket): fix bitbucket collection
1 parent ab5e84b commit 527d178

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# Output of the go coverage tool, specifically when used with LiteIDE
1414
*.out
1515

16-
1716
# Env file
1817
.env
1918

@@ -24,3 +23,4 @@
2423
.DS_store
2524

2625
/testdata
26+
src-fingerprint

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export GO111MODULE=on
2+
3+
4+
BIN := src-fingerprint
5+
6+
GO ?= go
7+
GOFLAGS := -v
8+
EXTRA_GOFLAGS ?=
9+
LDFLAGS := $(LDFLAGS)
10+
SOURCES ?= $(shell find ./* -name "*.go" -type f ! -path "./vendor/*")
11+
12+
.PHONY: default
13+
default: build
14+
15+
.PHONY: clean
16+
clean:
17+
$(GO) clean $(GOFLAGS) -i ./...
18+
rm -rf $(BIN)
19+
20+
.PHONY: lint
21+
lint:
22+
golangci-lint run
23+
24+
.PHONY: fmt
25+
fmt:
26+
go fmt ./...
27+
28+
.PHONY: test
29+
test:
30+
@test -z "$$(gofmt -l $(SOURCES))" || (echo "Files need to be linted. Use make fmt" && false)
31+
GIT_TERMINAL_PROMPT=0 $(GO) test $(GOFLAGS) ./... -coverprofile=.coverage.out
32+
go tool cover -func=.coverage.out
33+
34+
.PHONY: build
35+
build: $(BIN)
36+
37+
$(BIN): $(SOURCES)
38+
$(GO) build $(GOFLAGS) -ldflags '-s -w $(LDFLAGS)' $(EXTRA_GOFLAGS) -o $@ ./cmd/$(BIN)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ It supports 3 main on premise version control service:
88

99
- GitHub Enterprise
1010
- Gitlab CE and EE
11-
- BitBucket (not supported yet)
11+
- Bitbucket
1212

1313
## Use the package
1414

notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ repository|org|group|instance|org)
1717

1818
## To Do
1919

20-
- [ ] Support BitBucket
20+
- [x] Support Bitbucket
2121
- [ ] Implement a Redactor class to remove some data (repository name)
2222
- [x] Use cobra or other packages for the CLI
2323
- [ ] Implement CLI entry to scan a repo and not a full org.

provider/bitbucket.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func createFromBitbucketRepo(r *bitbucket.Repository) *Repository {
4040
}
4141
}
4242

43-
httpURL = strings.Replace(httpURL, "http", "https", 1)
43+
httpURL = strings.Replace(httpURL, "http://", "https://", 1)
4444

4545
return &Repository{
4646
name: r.Name,
@@ -59,7 +59,7 @@ type AuthHeaderTransport struct {
5959
}
6060

6161
func (at *AuthHeaderTransport) RoundTrip(req *http.Request) (*http.Response, error) {
62-
req.Header.Add("Authorization", at.token)
62+
req.Header.Add("Authorization", "Bearer "+at.token)
6363
resp, err := at.T.RoundTrip(req)
6464

6565
if resp != nil && resp.Header.Get("x-auserid") != "" {
@@ -120,7 +120,7 @@ func (p *BitbucketProvider) gatherPage(start int, project string) ([]GitReposito
120120
opt.ProjectName = project
121121
}
122122

123-
log.Infof("Gathering page %v for %v\n", start, p.client.BaseURL())
123+
log.Infof("Gathering page %v\n", start)
124124

125125
repos, resp, err := p.client.Repositories.List(context.Background(), opt)
126126
if err != nil {

0 commit comments

Comments
 (0)