// Copyright F3 Authors
// SPDX-License-Identifier: MIT

package f3

import (
	"fmt"

	"code.forgejo.org/f3/gof3/v3/f3"
	"code.forgejo.org/f3/gof3/v3/tree/generic"
)

type RepositoryDriverInterface interface {
	GetRepositoryURL() string
	GetRepositoryInternalRef() string

	GetPullRequestBranch(*f3.PullRequestBranch) *f3.PullRequestBranch
	CreatePullRequestBranch(*f3.PullRequestBranch)
	DeletePullRequestBranch(*f3.PullRequestBranch)
}

type RepositoryNodeDriverProxyInterface interface {
	RepositoryDriverInterface
}

type RepositoryNodeInterface interface {
	generic.NodeInterface
	RepositoryNodeDriverProxyInterface
}

func NewRepositoryPath(owners, owner, project, id string) generic.Path {
	return generic.NewNodePathFromString(NewRepositoryPathString(owners, owner, project, id))
}

func NewRepositoryPathString(owners, owner, project, id string) string {
	return fmt.Sprintf("%s/%s/%s/%s/%s/%s", owners, owner, f3.ResourceProjects, project, f3.ResourceRepositories, id)
}

func NewRepositoryReference(owners, owner, project, id string) *f3.Reference {
	return f3.NewReference(NewRepositoryPathString(owners, owner, project, id))
}

func NewPullRequestSameRepositoryReference() *f3.Reference {
	return f3.NewReference(fmt.Sprintf("../../%s/%s", f3.ResourceRepositories, f3.RepositoryNameDefault))
}
