1package backend
2
3import (
4 "github.com/charmbracelet/soft-serve/git"
5)
6
7// RepositoryOptions are options for creating a new repository.
8type RepositoryOptions struct {
9 Private bool
10 Description string
11 ProjectName string
12 Mirror bool
13 Hidden bool
14}
15
16// RepositoryStore is an interface for managing repositories.
17type RepositoryStore interface {
18 // Repository finds the given repository.
19 Repository(repo string) (Repository, error)
20 // Repositories returns a list of all repositories.
21 Repositories() ([]Repository, error)
22 // CreateRepository creates a new repository.
23 CreateRepository(name string, opts RepositoryOptions) (Repository, error)
24 // ImportRepository creates a new repository from a Git repository.
25 ImportRepository(name string, remote string, opts RepositoryOptions) (Repository, error)
26 // DeleteRepository deletes a repository.
27 DeleteRepository(name string) error
28 // RenameRepository renames a repository.
29 RenameRepository(oldName, newName string) error
30 // InitializeHooks initializes the hooks for the given repository.
31 InitializeHooks(repo string) error
32}
33
34// RepositoryMetadata is an interface for managing repository metadata.
35type RepositoryMetadata interface {
36 // ProjectName returns the repository's project name.
37 ProjectName(repo string) string
38 // SetProjectName sets the repository's project name.
39 SetProjectName(repo, name string) error
40 // Description returns the repository's description.
41 Description(repo string) string
42 // SetDescription sets the repository's description.
43 SetDescription(repo, desc string) error
44 // IsPrivate returns whether the repository is private.
45 IsPrivate(repo string) bool
46 // SetPrivate sets whether the repository is private.
47 SetPrivate(repo string, private bool) error
48 // IsMirror returns whether the repository is a mirror.
49 IsMirror(repo string) bool
50 // IsHidden returns whether the repository is hidden.
51 IsHidden(repo string) bool
52 // SetHidden sets whether the repository is hidden.
53 SetHidden(repo string, hidden bool) error
54}
55
56// RepositoryAccess is an interface for managing repository access.
57type RepositoryAccess interface {
58 IsCollaborator(repo string, username string) bool
59 // AddCollaborator adds the authorized key as a collaborator on the repository.
60 AddCollaborator(repo string, username string) error
61 // RemoveCollaborator removes the authorized key as a collaborator on the repository.
62 RemoveCollaborator(repo string, username string) error
63 // Collaborators returns a list of all collaborators on the repository.
64 Collaborators(repo string) ([]string, error)
65}
66
67// Repository is a Git repository interface.
68type Repository interface {
69 // Name returns the repository's name.
70 Name() string
71 // ProjectName returns the repository's project name.
72 ProjectName() string
73 // Description returns the repository's description.
74 Description() string
75 // IsPrivate returns whether the repository is private.
76 IsPrivate() bool
77 // IsMirror returns whether the repository is a mirror.
78 IsMirror() bool
79 // IsHidden returns whether the repository is hidden.
80 IsHidden() bool
81 // Open returns the underlying git.Repository.
82 Open() (*git.Repository, error)
83}