Skip to content

Commit

Permalink
refactor: rm unused parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
obcode committed Nov 5, 2024
1 parent 8efbc5e commit 59d1db0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
10 changes: 5 additions & 5 deletions gitlab/protect.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import (
)

func (c *Client) ProtectToBranch(assignmentCfg *config.AssignmentConfig) {
assignmentGitLabGroupID, err := c.getGroupID(assignmentCfg)
_, err := c.getGroupID(assignmentCfg)
if err != nil {
fmt.Printf("error: GitLab group for assignment does not exist, please create the group %s\n", assignmentCfg.URL)
os.Exit(1)
}

switch per := assignmentCfg.Per; per {
case config.PerGroup:
c.protectToBranchPerGroup(assignmentCfg, assignmentGitLabGroupID)
c.protectToBranchPerGroup(assignmentCfg)
case config.PerStudent:
c.protectToBranchPerStudent(assignmentCfg, assignmentGitLabGroupID)
c.protectToBranchPerStudent(assignmentCfg)
default:
fmt.Printf("it is only possible to protect the branch for students oder groups, not for %v", per)
os.Exit(1)
Expand Down Expand Up @@ -111,7 +111,7 @@ func (c *Client) protectBranch(assignmentCfg *config.AssignmentConfig, project *
return nil
}

func (c *Client) protectToBranchPerStudent(assignmentCfg *config.AssignmentConfig, assignmentGroupID int) {
func (c *Client) protectToBranchPerStudent(assignmentCfg *config.AssignmentConfig) {
if len(assignmentCfg.Students) == 0 {
fmt.Println("no students in config for assignment found")
return
Expand All @@ -134,7 +134,7 @@ func (c *Client) protectToBranchPerStudent(assignmentCfg *config.AssignmentConfi
}
}

func (c *Client) protectToBranchPerGroup(assignmentCfg *config.AssignmentConfig, assignmentGroupID int) {
func (c *Client) protectToBranchPerGroup(assignmentCfg *config.AssignmentConfig) {
if len(assignmentCfg.Groups) == 0 {
log.Info().Str("group", assignmentCfg.Course).Msg("no groups found")
return
Expand Down
10 changes: 5 additions & 5 deletions gitlab/setaccess.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import (
)

func (c *Client) Setaccess(assignmentCfg *config.AssignmentConfig) {
assignmentGitLabGroupID, err := c.getGroupID(assignmentCfg)
_, err := c.getGroupID(assignmentCfg)
if err != nil {
fmt.Printf("error: GitLab group for assignment does not exist, please create the group %s\n", assignmentCfg.URL)
os.Exit(1)
}

switch per := assignmentCfg.Per; per {
case config.PerGroup:
c.setaccessPerGroup(assignmentCfg, assignmentGitLabGroupID)
c.setaccessPerGroup(assignmentCfg)
case config.PerStudent:
c.setaccessPerStudent(assignmentCfg, assignmentGitLabGroupID)
c.setaccessPerStudent(assignmentCfg)
default:
fmt.Printf("it is only possible to set access levels for students oder groups, not for %v", per)
os.Exit(1)
Expand Down Expand Up @@ -153,7 +153,7 @@ func (c *Client) inviteByEmail(cfg *config.AssignmentConfig, projectID int, emai
return fmt.Sprintf("successfully invited user %s", email), nil
}

func (c *Client) setaccessPerStudent(assignmentCfg *config.AssignmentConfig, assignmentGroupID int) {
func (c *Client) setaccessPerStudent(assignmentCfg *config.AssignmentConfig) {
if len(assignmentCfg.Students) == 0 {
fmt.Println("no students in config for assignment found")
return
Expand All @@ -174,7 +174,7 @@ func (c *Client) setaccessPerStudent(assignmentCfg *config.AssignmentConfig, ass
}
}

func (c *Client) setaccessPerGroup(assignmentCfg *config.AssignmentConfig, assignmentGroupID int) {
func (c *Client) setaccessPerGroup(assignmentCfg *config.AssignmentConfig) {
if len(assignmentCfg.Groups) == 0 {
log.Info().Str("group", assignmentCfg.Course).Msg("no groups found")
return
Expand Down
12 changes: 5 additions & 7 deletions gitlab/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func (c *Client) Update(assignmentCfg *config.AssignmentConfig) {
assignmentGitLabGroupID, err := c.getGroupID(assignmentCfg)
_, err := c.getGroupID(assignmentCfg)
if err != nil {
fmt.Printf("error: GitLab group for assignment does not exist, please create the group %s\n", assignmentCfg.URL)
os.Exit(1)
Expand All @@ -33,9 +33,9 @@ func (c *Client) Update(assignmentCfg *config.AssignmentConfig) {

switch per := assignmentCfg.Per; per {
case config.PerGroup:
c.updatePerGroup(assignmentCfg, assignmentGitLabGroupID, starterrepo)
c.updatePerGroup(assignmentCfg, starterrepo)
case config.PerStudent:
c.updatePerStudent(assignmentCfg, assignmentGitLabGroupID, starterrepo)
c.updatePerStudent(assignmentCfg, starterrepo)
default:
fmt.Printf("it is only possible to update for students oder groups, not for %v", per)
os.Exit(1)
Expand Down Expand Up @@ -89,8 +89,7 @@ func (c *Client) update(assignmentCfg *config.AssignmentConfig, project *gitlab.
}
}

func (c *Client) updatePerStudent(assignmentCfg *config.AssignmentConfig, assignmentGroupID int,
starterrepo *git.Starterrepo) {
func (c *Client) updatePerStudent(assignmentCfg *config.AssignmentConfig, starterrepo *git.Starterrepo) {
if len(assignmentCfg.Students) == 0 {
log.Info().Str("group", assignmentCfg.Course).Msg("no students found")
return
Expand All @@ -111,8 +110,7 @@ func (c *Client) updatePerStudent(assignmentCfg *config.AssignmentConfig, assign
}
}

func (c *Client) updatePerGroup(assignmentCfg *config.AssignmentConfig, assignmentGroupID int,
starterrepo *git.Starterrepo) {
func (c *Client) updatePerGroup(assignmentCfg *config.AssignmentConfig, starterrepo *git.Starterrepo) {
if len(assignmentCfg.Groups) == 0 {
log.Info().Str("group", assignmentCfg.Course).Msg("no groups found")
return
Expand Down

0 comments on commit 59d1db0

Please sign in to comment.