github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/api/buildplanner/request/revertcommit.go (about)

     1  package request
     2  
     3  import (
     4  	"github.com/ActiveState/cli/pkg/platform/api/buildplanner/types"
     5  )
     6  
     7  func RevertCommit(organization, project, targetVcsRef, commitID string) *revertCommit {
     8  	return &revertCommit{map[string]interface{}{
     9  		"organization": organization,
    10  		"project":      project,
    11  		"targetVcsRef": targetVcsRef,
    12  		"commitId":     commitID,
    13  		// Currently, we use the force strategy for all revert commits.
    14  		// This is because we don't have a way to show the user the conflicts
    15  		// and let them resolve them yet.
    16  		// https://activestatef.atlassian.net/browse/AR-80?focusedCommentId=46998
    17  		"strategy": types.RevertCommitStrategyForce,
    18  	}}
    19  }
    20  
    21  type revertCommit struct {
    22  	vars map[string]interface{}
    23  }
    24  
    25  func (r *revertCommit) Query() string {
    26  	return `
    27  mutation ($organization: String!, $project: String!, $commitId: String!, $targetVcsRef: String!, $strategy: RevertStrategy) {
    28    revertCommit(
    29      input: {organization: $organization, project: $project, commitId: $commitId, targetVcsRef: $targetVcsRef, strategy: $strategy}
    30    ) {
    31      ... on RevertedCommit {
    32        __typename
    33        commit {
    34          __typename
    35          commitId
    36        }
    37      }
    38      ... on RevertConflict {
    39        __typename
    40        message
    41        commitId
    42        targetCommitId
    43        conflictPaths
    44      }
    45      ... on CommitHasNoParent {
    46        __typename
    47        message
    48      }
    49      ... on NotFound {
    50        __typename
    51        message
    52        mayNeedAuthentication
    53      }
    54      ... on ParseError {
    55        __typename
    56        message
    57        path
    58      }
    59      ... on ValidationError {
    60        __typename
    61        message
    62      }
    63      ... on Forbidden {
    64        __typename
    65        message
    66      }
    67      ... on HeadOnBranchMoved {
    68        __typename
    69        message
    70      }
    71      ... on NoChangeSinceLastCommit {
    72        message
    73        commitId
    74      }
    75    }
    76  }`
    77  }
    78  
    79  func (r *revertCommit) Vars() (map[string]interface{}, error) {
    80  	return r.vars, nil
    81  }