@@ -6,7 +6,6 @@ package vcs
6
6
7
7
import (
8
8
"bytes"
9
- "encoding/json"
10
9
"errors"
11
10
"fmt"
12
11
exec "internal/execabs"
@@ -1437,8 +1436,9 @@ var vcsPaths = []*vcsPath{
1437
1436
{
1438
1437
pathPrefix : "bitbucket.org" ,
1439
1438
regexp : lazyregexp .New (`^(?P<root>bitbucket\.org/(?P<bitname>[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+))(/[A-Za-z0-9_.\-]+)*$` ),
1439
+ vcs : "git" ,
1440
1440
repo : "https://{root}" ,
1441
- check : bitbucketVCS ,
1441
+ check : noVCSSuffix ,
1442
1442
},
1443
1443
1444
1444
// IBM DevOps Services (JazzHub)
@@ -1510,56 +1510,6 @@ func noVCSSuffix(match map[string]string) error {
1510
1510
return nil
1511
1511
}
1512
1512
1513
- // bitbucketVCS determines the version control system for a
1514
- // Bitbucket repository, by using the Bitbucket API.
1515
- func bitbucketVCS (match map [string ]string ) error {
1516
- if err := noVCSSuffix (match ); err != nil {
1517
- return err
1518
- }
1519
-
1520
- var resp struct {
1521
- SCM string `json:"scm"`
1522
- }
1523
- url := & urlpkg.URL {
1524
- Scheme : "https" ,
1525
- Host : "api.bitbucket.org" ,
1526
- Path : expand (match , "/2.0/repositories/{bitname}" ),
1527
- RawQuery : "fields=scm" ,
1528
- }
1529
- data , err := web .GetBytes (url )
1530
- if err != nil {
1531
- if httpErr , ok := err .(* web.HTTPError ); ok && httpErr .StatusCode == 403 {
1532
- // this may be a private repository. If so, attempt to determine which
1533
- // VCS it uses. See issue 5375.
1534
- root := match ["root" ]
1535
- for _ , vcs := range []string {"git" , "hg" } {
1536
- if vcsByCmd (vcs ).Ping ("https" , root ) == nil {
1537
- resp .SCM = vcs
1538
- break
1539
- }
1540
- }
1541
- }
1542
-
1543
- if resp .SCM == "" {
1544
- return err
1545
- }
1546
- } else {
1547
- if err := json .Unmarshal (data , & resp ); err != nil {
1548
- return fmt .Errorf ("decoding %s: %v" , url , err )
1549
- }
1550
- }
1551
-
1552
- if vcsByCmd (resp .SCM ) != nil {
1553
- match ["vcs" ] = resp .SCM
1554
- if resp .SCM == "git" {
1555
- match ["repo" ] += ".git"
1556
- }
1557
- return nil
1558
- }
1559
-
1560
- return fmt .Errorf ("unable to detect version control system for bitbucket.org/ path" )
1561
- }
1562
-
1563
1513
// launchpadVCS solves the ambiguity for "lp.net/project/foo". In this case,
1564
1514
// "foo" could be a series name registered in Launchpad with its own branch,
1565
1515
// and it could also be the name of a directory within the main project
0 commit comments