Feat: support nested folders in namespace (#87)

This MR fixes an issue with nested namespaces. It also adds CI to the project for Go tests.
This commit is contained in:
Louis LIN
2023-11-13 03:11:37 +01:00
committed by GitHub
parent 80b597e56a
commit 59557e464b
6 changed files with 243 additions and 25 deletions

View File

@@ -80,21 +80,20 @@ func (c *Client) initGitlabClient() error {
}
/* This will fetch the project ID and merge request ID using the client */
func (c *Client) initProjectSettings(remoteUrl string, namespace string, projectName string, branchName string) error {
func (c *Client) initProjectSettings(g GitProjectInfo) error {
idStr := namespace + "/" + projectName
opt := gitlab.GetProjectOptions{}
project, _, err := c.git.Projects.GetProject(idStr, &opt)
project, _, err := c.git.Projects.GetProject(g.projectPath(), &opt)
if err != nil {
return fmt.Errorf(fmt.Sprintf("Error getting project at %s", remoteUrl), err)
return fmt.Errorf(fmt.Sprintf("Error getting project at %s", g.RemoteUrl), err)
}
if project == nil {
return fmt.Errorf(fmt.Sprintf("Could not find project at %s", remoteUrl), err)
return fmt.Errorf(fmt.Sprintf("Could not find project at %s", g.RemoteUrl), err)
}
if project == nil {
return fmt.Errorf("No projects you are a member of contained remote URL %s", remoteUrl)
return fmt.Errorf("No projects you are a member of contained remote URL %s", g.RemoteUrl)
}
c.projectId = fmt.Sprint(project.ID)
@@ -102,7 +101,7 @@ func (c *Client) initProjectSettings(remoteUrl string, namespace string, project
options := gitlab.ListProjectMergeRequestsOptions{
Scope: gitlab.String("all"),
State: gitlab.String("opened"),
SourceBranch: &branchName,
SourceBranch: &g.BranchName,
}
mergeRequests, _, err := c.git.MergeRequests.ListProjectMergeRequests(c.projectId, &options)