Skip to content

fix: createPullRequest target branch handling#857

Open
PRAteek-singHWY wants to merge 1 commit intoOWASP:mainfrom
PRAteek-singHWY:fix/createpullrequest-target-branch
Open

fix: createPullRequest target branch handling#857
PRAteek-singHWY wants to merge 1 commit intoOWASP:mainfrom
PRAteek-singHWY:fix/createpullrequest-target-branch

Conversation

@PRAteek-singHWY
Copy link
Copy Markdown
Contributor

Note

This is a small, scoped helper bugfix with targeted regression tests.
Given the limited scope, no separate issue was opened to avoid extra triage overhead.

Summary

This PR fixes base-branch selection in the GitHub PR helper.

createPullRequest(...) accepted a targetBranch argument, but the implementation always used base="master".
As a result, callers could not control the PR target branch.

Issue

  • application/utils/git.py
  • createPullRequest(...) ignored the provided targetBranch
  • Risk: PRs can be opened against the wrong base branch

Scope

  • Focused bug fix only
  • No unrelated logic changes
  • Backward-compatible default behavior remains unchanged

Changes

  • Updated application/utils/git.py:
    • create_pull(..., base="master") -> create_pull(..., base=targetBranch)
    • Log message updated to print the actual target branch
  • Added regression tests in:
    • application/tests/git_utils_test.py

Test File

  • application/tests/git_utils_test.py

Test Description

The new test file validates both explicit and default behavior:

  1. test_create_pull_request_uses_target_branch
  • Mocks GitHub client/repo
  • Calls createPullRequest(..., targetBranch="main")
  • Asserts repo.create_pull(...) is called with base="main"
  1. test_create_pull_request_defaults_to_master
  • Mocks GitHub client/repo
  • Calls createPullRequest(...) without targetBranch
  • Asserts repo.create_pull(...) is called with base="master"

Validation

Ran:

./venv/bin/python -m pytest application/tests/git_utils_test.py -q

Result:

  • 2 passed

@PRAteek-singHWY PRAteek-singHWY changed the title Fix createPullRequest target branch handling fix: createPullRequest target branch handling Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant