diff --git a/plugins/git-release-manager/src/api/GitReleaseApiClient.ts b/plugins/git-release-manager/src/api/GitReleaseApiClient.ts index 4a837a02e1..d35b5a043b 100644 --- a/plugins/git-release-manager/src/api/GitReleaseApiClient.ts +++ b/plugins/git-release-manager/src/api/GitReleaseApiClient.ts @@ -401,6 +401,7 @@ export class GitReleaseApiClient implements GitReleaseApi { selectedPatchCommit, mergeTree, releaseBranchSha, + messageSuffix, }) => { const { octokit } = await this.getOctokit(); const { data: cherryPickCommit } = await octokit.git.createCommit({ @@ -408,7 +409,7 @@ export class GitReleaseApiClient implements GitReleaseApi { repo, message: `[patch ${bumpedTag}] ${selectedPatchCommit.commit.message} -${selectedPatchCommit.sha}`, +${messageSuffix}`, tree: mergeTree, parents: [releaseBranchSha], }); @@ -757,6 +758,7 @@ export interface GitReleaseApi { >; mergeTree: string; releaseBranchSha: string; + messageSuffix: string; } & OwnerRepo, ) => Promise<{ message: string; diff --git a/plugins/git-release-manager/src/features/Patch/PatchBody.tsx b/plugins/git-release-manager/src/features/Patch/PatchBody.tsx index ab2769e2a1..8e916afa2e 100644 --- a/plugins/git-release-manager/src/features/Patch/PatchBody.tsx +++ b/plugins/git-release-manager/src/features/Patch/PatchBody.tsx @@ -42,6 +42,7 @@ import { CalverTagParts } from '../../helpers/tagParts/getCalverTagParts'; import { CenteredCircularProgress } from '../../components/CenteredCircularProgress'; import { ComponentConfigPatch } from '../../types/types'; import { Differ } from '../../components/Differ'; +import { getPatchCommitSuffix } from './helpers/getPatchCommitSuffix'; import { gitReleaseManagerApiRef } from '../../api/serviceApiRef'; import { GitReleaseManagerError } from '../../errors/GitReleaseManagerError'; import { ResponseStepDialog } from '../../components/ResponseStepDialog/ResponseStepDialog'; @@ -159,7 +160,11 @@ export const PatchBody = ({ const commitExistsOnReleaseBranch = !!gitDataResponse.value?.recentCommitsOnReleaseBranch.find( releaseBranchCommit => releaseBranchCommit.sha === commit.sha || - releaseBranchCommit.commit.message.includes(commit.sha), // The selected patch commit's sha is included in the commit message + // The selected patch commit's sha is included in the commit message, + // which means it's part of a previous patch + releaseBranchCommit.commit.message.includes( + getPatchCommitSuffix({ commitSha: commit.sha }), + ), ); const hasNoParent = !commit.firstParentSha; diff --git a/plugins/git-release-manager/src/features/Patch/helpers/getPatchCommitSuffix.ts b/plugins/git-release-manager/src/features/Patch/helpers/getPatchCommitSuffix.ts new file mode 100644 index 0000000000..09b867fd25 --- /dev/null +++ b/plugins/git-release-manager/src/features/Patch/helpers/getPatchCommitSuffix.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2021 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const getPatchCommitSuffix = ({ commitSha }: { commitSha: string }) => { + return `[Backstage patch ${commitSha}]`; +}; diff --git a/plugins/git-release-manager/src/features/Patch/hooks/usePatch.ts b/plugins/git-release-manager/src/features/Patch/hooks/usePatch.ts index 7ae8ed920b..bc71267089 100644 --- a/plugins/git-release-manager/src/features/Patch/hooks/usePatch.ts +++ b/plugins/git-release-manager/src/features/Patch/hooks/usePatch.ts @@ -24,11 +24,12 @@ import { } from '../../../api/GitReleaseApiClient'; import { CalverTagParts } from '../../../helpers/tagParts/getCalverTagParts'; import { ComponentConfigPatch, CardHook } from '../../../types/types'; +import { getPatchCommitSuffix } from '../helpers/getPatchCommitSuffix'; import { gitReleaseManagerApiRef } from '../../../api/serviceApiRef'; import { Project } from '../../../contexts/ProjectContext'; import { SemverTagParts } from '../../../helpers/tagParts/getSemverTagParts'; -import { useResponseSteps } from '../../../hooks/useResponseSteps'; import { TAG_OBJECT_MESSAGE } from '../../../constants/constants'; +import { useResponseSteps } from '../../../hooks/useResponseSteps'; import { useUserContext } from '../../../contexts/UserContext'; interface Patch { @@ -190,6 +191,9 @@ export function usePatch({ mergeTree: mergeRes.value.commit.tree.sha, releaseBranchSha, selectedPatchCommit: releaseBranchRes.value.selectedPatchCommit, + messageSuffix: getPatchCommitSuffix({ + commitSha: releaseBranchRes.value.selectedPatchCommit.sha, + }), }) .catch(asyncCatcher);