Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to take action on a MR depending on various setttings #8

Merged
merged 13 commits into from
May 8, 2024
Merged
Prev Previous commit
Next Next commit
fix: undo mods to label system
jippi committed May 7, 2024
commit 1c805dc936da6890bc6fad7ec9d8a533cdfb77a3
21 changes: 0 additions & 21 deletions pkg/scm/gitlab/context.model.go

This file was deleted.

13 changes: 1 addition & 12 deletions schema/gitlab.go
Original file line number Diff line number Diff line change
@@ -68,8 +68,6 @@ func nest(props []*Property) {
for _, field := range props {

if field.IsCustomType {
fmt.Println("nesting", field.Name, "of type", field.Type)

for _, nested := range PropMap[field.Type].Attributes {
field.AddAttribute(&Property{
Name: nested.Name,
@@ -198,11 +196,9 @@ func mutateHook(b *modelgen.ModelBuild) *modelgen.ModelBuild {
}

fieldProperty.Type = strings.TrimPrefix(fieldType, "*")
fieldProperty.IsSlice = strings.HasPrefix(fieldType, "[]") || fieldType == "labels"
fieldProperty.IsSlice = strings.HasPrefix(fieldType, "[]") || fieldType == "label"

modelProperty.AddAttribute(fieldProperty)

fmt.Println(" ", fieldProperty.Name, "of type", fieldProperty.Type)
} // end expr tag is set

slices.SortFunc(modelProperty.Attributes, sortSlice)
@@ -214,13 +210,6 @@ func mutateHook(b *modelgen.ModelBuild) *modelgen.ModelBuild {
continue
}

if modelProperty.Type == "label" {
modelProperty.Type = "labels"
modelProperty.IsSlice = true
}

fmt.Println("Registering custom model", modelProperty.Name, "of type", modelProperty.Type)

Props = append(Props, modelProperty)
PropMap[modelProperty.Type] = modelProperty
} // end model loop
3 changes: 0 additions & 3 deletions schema/gitlab.gqlgen.yml
Original file line number Diff line number Diff line change
@@ -88,6 +88,3 @@ models:
Duration:
model:
- github.com/99designs/gqlgen/graphql.Duration
ContextLabels:
model:
- ../pkg/scm/gitlab.ContextLabels
6 changes: 2 additions & 4 deletions schema/gitlab.schema.graphqls
Original file line number Diff line number Diff line change
@@ -21,8 +21,6 @@ scalar Time
# Add time.Duration support
scalar Duration

scalar ContextLabels

type Context {
"The project the Merge Request belongs to"
Project: ContextProject @graphql(key: "project(fullPath: $project_id)")
@@ -68,7 +66,7 @@ type ContextProject {
# Connections
#

Labels: ContextLabels @generated
Labels: [ContextLabel!] @generated
ResponseLabels: ContextLabelNode @internal @graphql(key: "labels(first: 200)")
MergeRequest: ContextMergeRequest @internal @graphql(key: "mergeRequest(iid: $mr_id)")
ResponseGroup: ContextGroup @internal @graphql(key: "group")
@@ -180,7 +178,7 @@ type ContextMergeRequest {
#

DiffStats: [ContextDiffStat!]
Labels: ContextLabels @generated
Labels: [ContextLabel!] @generated
ResponseLabels: ContextLabelNode @internal @graphql(key: "labels(first: 200)")
ResponseFirstCommits: ContextCommitsNode @internal @graphql(key: "first_commit: commits(first:1)")
ResponseLastCommits: ContextCommitsNode @internal @graphql(key: "last_commit: commits(last:1)")