2024-01-16 16:15:52 +00:00
|
|
|
package gitlabremote
|
|
|
|
|
|
|
|
import (
|
2024-01-16 19:26:56 +00:00
|
|
|
"fmt"
|
|
|
|
|
2024-01-16 16:15:52 +00:00
|
|
|
"github.com/xanzy/go-gitlab"
|
2024-12-19 19:55:49 +00:00
|
|
|
"gitea.libretechconsulting.com/rmcguire/git-project-manager/internal/remotes/info"
|
2024-01-16 16:15:52 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type GitlabRemote struct {
|
2024-01-17 13:13:58 +00:00
|
|
|
info *info.RemoteInfo
|
2024-01-16 16:15:52 +00:00
|
|
|
api *gitlab.Client
|
|
|
|
}
|
|
|
|
|
2024-01-17 13:13:58 +00:00
|
|
|
func (r *GitlabRemote) GetInfo() *info.RemoteInfo {
|
2024-01-16 16:15:52 +00:00
|
|
|
return r.info
|
|
|
|
}
|
|
|
|
|
2024-01-17 13:13:58 +00:00
|
|
|
func (r *GitlabRemote) GetType() string {
|
2024-01-17 21:56:41 +00:00
|
|
|
return r.info.Type.String()
|
2024-01-17 13:13:58 +00:00
|
|
|
}
|
|
|
|
|
2024-01-16 19:26:56 +00:00
|
|
|
func (r *GitlabRemote) String() string {
|
|
|
|
return fmt.Sprintf("GitLab %s (%s), clone proto %s",
|
|
|
|
r.GetInfo().Name, r.GetInfo().Host, r.GetInfo().CloneProto)
|
|
|
|
}
|
|
|
|
|
2024-01-17 13:13:58 +00:00
|
|
|
func NewGitlabRemote(remoteInfo *info.RemoteInfo) (*GitlabRemote, error) {
|
2024-01-16 16:15:52 +00:00
|
|
|
api, err := NewGitlabApi(remoteInfo)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
gl := &GitlabRemote{
|
|
|
|
info: remoteInfo,
|
|
|
|
api: api,
|
|
|
|
}
|
|
|
|
return gl, nil
|
|
|
|
}
|