fix: use API for creating branch and fetching hashes when committing using Github API #2070
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #1914 and issues described in this comment.
Note: I will probably not have time to add any tests this week, so feel free to take over @olblak or if approve if you feel it's good enough since most are API actions that can't be properly tested without integration tests.
The previous implementation used native Git to both create the working branch and fetching latest commit hash used when committing using API. This caused issues when using multiple targets with the same SCM due to the local cloned repository not having pulled the latest changes from the remote branch, which meant that
PushBranch
reverted changes done in the first target that ran.To fix this, I've added the following:
Test
Additional Information
Potential improvement
The
queryHeadOid
function use much of the same code asqueryRepository
but this function fails if the working branch is not available due to it being used as an input. We could probably rework this to be a more dynamic struct, but I think having an explicit function that only fetches the required information (i.e. hashes) makes sense even if it's not following DRY.