diff --git a/internal/runbits/requirements/requirements.go b/internal/runbits/requirements/requirements.go index 684aa373b1..0e368828b2 100644 --- a/internal/runbits/requirements/requirements.go +++ b/internal/runbits/requirements/requirements.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "strconv" "strings" "github.com/ActiveState/cli/internal/analytics" @@ -242,6 +243,7 @@ func (r *RequirementOperation) ExecuteRequirementOperation(requirementName, requ Owner: pj.Owner(), Project: pj.Name(), ParentCommit: string(parentCommitID), + Description: commitMessage(operation, name, version, ns, requirementBitWidth), RequirementName: name, RequirementVersion: requirements, RequirementNamespace: ns, @@ -418,3 +420,61 @@ func initializeProject() (*project.Project, error) { return project.FromPath(target) } + +func commitMessage(op bpModel.Operation, name, version string, namespace model.Namespace, word int) string { + switch namespace.Type() { + case model.NamespaceLanguage: + return languageCommitMessage(op, name, version) + case model.NamespacePlatform: + return platformCommitMessage(op, name, version, word) + case model.NamespacePackage, model.NamespaceBundle: + return packageCommitMessage(op, name, version) + } + + return "" +} + +func languageCommitMessage(op bpModel.Operation, name, version string) string { + var msgL10nKey string + switch op { + case bpModel.OperationAdded: + msgL10nKey = "commit_message_added_language" + case bpModel.OperationUpdated: + msgL10nKey = "commit_message_updated_language" + case bpModel.OperationRemoved: + msgL10nKey = "commit_message_removed_language" + } + + return locale.Tr(msgL10nKey, name, version) +} + +func platformCommitMessage(op bpModel.Operation, name, version string, word int) string { + var msgL10nKey string + switch op { + case bpModel.OperationAdded: + msgL10nKey = "commit_message_added_platform" + case bpModel.OperationUpdated: + msgL10nKey = "commit_message_updated_platform" + case bpModel.OperationRemoved: + msgL10nKey = "commit_message_removed_platform" + } + + return locale.Tr(msgL10nKey, name, strconv.Itoa(word), version) +} + +func packageCommitMessage(op bpModel.Operation, name, version string) string { + var msgL10nKey string + switch op { + case bpModel.OperationAdded: + msgL10nKey = "commit_message_added_package" + case bpModel.OperationUpdated: + msgL10nKey = "commit_message_updated_package" + case bpModel.OperationRemoved: + msgL10nKey = "commit_message_removed_package" + } + + if version == "" { + version = locale.Tl("package_version_auto", "auto") + } + return locale.Tr(msgL10nKey, name, version) +} diff --git a/pkg/platform/api/buildplanner/request/stagecommit.go b/pkg/platform/api/buildplanner/request/stagecommit.go index c1c8d10ff4..4141fdee76 100644 --- a/pkg/platform/api/buildplanner/request/stagecommit.go +++ b/pkg/platform/api/buildplanner/request/stagecommit.go @@ -2,11 +2,12 @@ package request import "github.com/ActiveState/cli/pkg/platform/runtime/buildexpression" -func StageCommit(owner, project, parentCommit string, expression *buildexpression.BuildExpression) *buildPlanByStageCommit { +func StageCommit(owner, project, parentCommit, description string, expression *buildexpression.BuildExpression) *buildPlanByStageCommit { return &buildPlanByStageCommit{map[string]interface{}{ "organization": owner, "project": project, "parentCommit": parentCommit, + "description": description, "expr": expression, }} } @@ -17,8 +18,8 @@ type buildPlanByStageCommit struct { func (b *buildPlanByStageCommit) Query() string { return ` -mutation ($organization: String!, $project: String!, $parentCommit: ID, $expr:BuildExpr!) { - stageCommit(input:{organization:$organization, project:$project, parentCommitId:$parentCommit, expr:$expr}) { +mutation ($organization: String!, $project: String!, $parentCommit: ID, $description: String!, $expr:BuildExpr!) { + stageCommit(input:{organization:$organization, project:$project, parentCommitId:$parentCommit, description:$description, expr:$expr}) { ... on Commit { __typename expr diff --git a/pkg/platform/model/buildplanner.go b/pkg/platform/model/buildplanner.go index a3673080de..c1ef78b35f 100644 --- a/pkg/platform/model/buildplanner.go +++ b/pkg/platform/model/buildplanner.go @@ -243,6 +243,7 @@ type StageCommitParams struct { Owner string Project string ParentCommit string + Description string // Commits can have either an operation (e.g. installing a package)... RequirementName string RequirementVersion []bpModel.VersionRequirement @@ -290,7 +291,7 @@ func (bp *BuildPlanner) StageCommit(params StageCommitParams) (strfmt.UUID, erro } // With the updated build expression call the stage commit mutation - request := request.StageCommit(params.Owner, params.Project, params.ParentCommit, expression) + request := request.StageCommit(params.Owner, params.Project, params.ParentCommit, params.Description, expression) resp := &bpModel.StageCommitResult{} err := bp.client.Run(request, resp) if err != nil { diff --git a/pkg/platform/model/vcs.go b/pkg/platform/model/vcs.go index f42acd88de..1556b33b57 100644 --- a/pkg/platform/model/vcs.go +++ b/pkg/platform/model/vcs.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" "regexp" - "strconv" "strings" "github.com/ActiveState/cli/internal/constants" @@ -668,64 +667,6 @@ func (cs indexedCommits) countBetween(first, last string) (int, error) { return ct, nil } -func commitMessage(op Operation, name, version string, namespace Namespace, word int) string { - switch namespace.Type() { - case NamespaceLanguage: - return languageCommitMessage(op, name, version) - case NamespacePlatform: - return platformCommitMessage(op, name, version, word) - case NamespacePackage, NamespaceBundle: - return packageCommitMessage(op, name, version) - } - - return "" -} - -func languageCommitMessage(op Operation, name, version string) string { - var msgL10nKey string - switch op { - case OperationAdded: - msgL10nKey = "commit_message_added_language" - case OperationUpdated: - msgL10nKey = "commit_message_updated_language" - case OperationRemoved: - msgL10nKey = "commit_message_removed_language" - } - - return locale.Tr(msgL10nKey, name, version) -} - -func platformCommitMessage(op Operation, name, version string, word int) string { - var msgL10nKey string - switch op { - case OperationAdded: - msgL10nKey = "commit_message_added_platform" - case OperationUpdated: - msgL10nKey = "commit_message_updated_platform" - case OperationRemoved: - msgL10nKey = "commit_message_removed_platform" - } - - return locale.Tr(msgL10nKey, name, strconv.Itoa(word), version) -} - -func packageCommitMessage(op Operation, name, version string) string { - var msgL10nKey string - switch op { - case OperationAdded: - msgL10nKey = "commit_message_added_package" - case OperationUpdated: - msgL10nKey = "commit_message_updated_package" - case OperationRemoved: - msgL10nKey = "commit_message_removed_package" - } - - if version == "" { - version = locale.Tl("package_version_auto", "auto") - } - return locale.Tr(msgL10nKey, name, version) -} - func ResolveRequirementNameAndVersion(name, version string, word int, namespace Namespace) (string, string, error) { if namespace.Type() == NamespacePlatform { platform, err := FetchPlatformByDetails(name, version, word)