Fix attr reader to force the intended values for source and target shas
What does this MR do?
When importing a pull request from GitHub, the old and new branches may no longer actually exist by those names, but we need to recreate the merge
request diff with the right source and target shas. We use these target_branch_sha
and source_branch_sha
attributes to force these to the intended values. But the reader methods were always looking up to the target/source branch head instead of check if these values was previously set, this MR applies a memoization pattern to both of them.
Are there points in the code the reviewer needs to double check?
This commit introduced this bug in the importer.
What are the relevant issue numbers?
gitlab-org/gitlab-ce#20385
Does this MR meet the acceptance criteria?
-
CHANGELOG entry added -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the style guides -
Branch has no merge conflicts with master
(if you do - rebase it please) -
Squashed related commits together
/cc @akitaonrails @DouweM