func (rr RepositoryReference) String() string {
	return fmt.Sprintf("%s/%s", rr.ProjectKey, rr.Name)
}
String returns the string representation of a repo reference
package bitbucketserver
import (
	"bytes"
	"context"
	"crypto/tls"
	"encoding/base64"
	"encoding/json"
	"fmt"
	"net/http"
	"net/url"
	"path"
	"sort"
	"strings"
	bitbucketv1 "github.com/gfleury/go-bitbucket-v1"
	"github.com/lindell/multi-gitter/internal/scm"
	"github.com/mitchellh/mapstructure"
	"github.com/pkg/errors"
)
const (
	cloneType     = "http"
	stateMerged   = "MERGED"
	stateDeclined = "DECLINED"
)
func New(username, token, baseURL string, insecure bool, transportMiddleware func(http.RoundTripper) http.RoundTripper, repoListing RepositoryListing) (*BitbucketServer, error) {
	if strings.TrimSpace(token) == "" {
		return nil, errors.New("token is empty")
	}
	if strings.TrimSpace(baseURL) == "" {
		return nil, errors.New("base url is empty")
	}
	bitbucketBaseURL, err := url.Parse(baseURL)
	if err != nil {
		return nil, err
	}
	if !strings.HasSuffix(bitbucketBaseURL.Path, "/rest") {
		bitbucketBaseURL.Path = path.Join(bitbucketBaseURL.Path, "/rest")
	}
	bitbucketServer := &BitbucketServer{}
	bitbucketServer.RepositoryListing = repoListing
	bitbucketServer.baseURL = bitbucketBaseURL
	bitbucketServer.username = username
	bitbucketServer.token = token
	bitbucketServer.httpClient = &http.Client{
		Transport: transportMiddleware(&http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure},  
		}),
	}
	bitbucketServer.config = bitbucketv1.NewConfiguration(bitbucketBaseURL.String(), func(config *bitbucketv1.Configuration) {
		config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token))
		config.HTTPClient = &http.Client{
			Transport: transportMiddleware(&http.Transport{
				TLSClientConfig: &tls.Config{InsecureSkipVerify: insecure},  
			}),
		}
	})
	return bitbucketServer, nil
}
func newClient(ctx context.Context, config *bitbucketv1.Configuration) *bitbucketv1.APIClient {
	return bitbucketv1.NewAPIClient(
		ctx,
		config,
	)
}
type BitbucketServer struct {
	RepositoryListing
	baseURL         *url.URL
	username, token string
	config          *bitbucketv1.Configuration
	httpClient      *http.Client
}
type RepositoryListing struct {
	Projects     []string
	Users        []string
	Repositories []RepositoryReference
}
type RepositoryReference struct {
	ProjectKey string
	Name       string
}
func ParseRepositoryReference(val string) (RepositoryReference, error) {
	split := strings.Split(val, "/")
	if len(split) != 2 {
		return RepositoryReference{}, fmt.Errorf("could not parse repository reference: %s", val)
	}
	return RepositoryReference{
		ProjectKey: split[0],
		Name:       split[1],
	}, nil
}