Skip to content

Commit 5311437

Browse files
committed
Ensure we don't update source/target unless we need to
1 parent b212935 commit 5311437

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/Share/Postgres/Contributions/Queries.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,7 @@ updateContribution callerUserId contributionId newTitle newDescription newStatus
291291
-- messes with the diffs.
292292
-- But we do want to update them if the source or target branch has changed.
293293
when
294-
( updatedStatus == InReview
295-
|| updatedStatus == Draft
296-
|| newSourceBranchId /= (Just sourceBranchId)
297-
|| newTargetBranchId /= (Just targetBranchId)
298-
)
294+
(updatedStatus == InReview || updatedStatus == Draft)
299295
do
300296
lift $
301297
PG.execute_
@@ -543,7 +539,11 @@ rebaseContributionsFromMergedBranches mergedContributions = do
543539
)
544540
UPDATE contributions contr
545541
SET target_branch = merged_contribution.target_branch,
546-
target_causal_id = new_target_branch.causal_id
542+
target_causal_id = new_target_branch.causal_id,
543+
best_common_ancestor_causal_id = best_common_causal_ancestor(
544+
contr.source_causal_id,
545+
new_target_branch.causal_id
546+
)
547547
-- Update all open contributions which are merging into a branch that was just merged
548548
FROM merged_contribution_ids
549549
JOIN contributions merged_contribution ON merged_contribution.id = merged_contribution_ids.contribution_id

src/Share/Web/Share/Contributions/MergeDetection.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Share.Postgres.Contributions.Queries qualified as ContributionQ
1414
updateContributionsFromBranchUpdate :: UserId -> BranchId -> PG.Transaction e ()
1515
updateContributionsFromBranchUpdate callerUserId branchId = do
1616
contributionsWithUpdatedBCAs <- ContributionQ.performMergesAndBCAUpdatesFromBranchPush callerUserId branchId
17-
_rebasedContributions <- ContributionQ.rebaseContributionsFromMergedBranches contributionsWithUpdatedBCAs
17+
rebasedContributions <- ContributionQ.rebaseContributionsFromMergedBranches contributionsWithUpdatedBCAs
1818
affectedContributions <- ContributionQ.contributionsRelatedToBranches (Set.singleton branchId)
19-
DiffsQ.submitContributionsToBeDiffed (Set.fromList affectedContributions)
19+
DiffsQ.submitContributionsToBeDiffed (Set.fromList affectedContributions <> rebasedContributions)
2020
pure ()

0 commit comments

Comments
 (0)