Skip to content

Add setting to auto fetch after merge request creation#153

Open
subhajitlucky wants to merge 2 commits into
zigcBenx:masterfrom
subhajitlucky:auto-fetch-after-mr-28
Open

Add setting to auto fetch after merge request creation#153
subhajitlucky wants to merge 2 commits into
zigcBenx:masterfrom
subhajitlucky:auto-fetch-after-mr-28

Conversation

@subhajitlucky
Copy link
Copy Markdown

Fixes #28

Summary

  • add auto_fetch_after_merge_request config support
  • run git fetch origin after the merge request is created when that setting is enabled
  • document the setting in the example config and add regression coverage

Verification

  • python3 -m unittest tests.test_auto_fetch_after_merge_request -v
  • python3 -m unittest discover -v
  • python3 -m compileall gitHappens.py tests
  • git diff --check

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional configuration flag to automatically git fetch origin immediately after creating a GitLab merge request, and documents/tests the behavior to address issue #28.

Changes:

  • Add auto_fetch_after_merge_request config parsing and conditionally run git fetch origin after MR creation.
  • Document the new setting in configs/config.ini.example.
  • Add a regression test covering the enabled behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
gitHappens.py Parses new config flag and conditionally runs git fetch origin after merge request creation.
configs/config.ini.example Documents auto_fetch_after_merge_request with a default of false.
tests/test_auto_fetch_after_merge_request.py Adds unit test for the “enabled” fetch behavior during MR creation flow.
tests/__init__.py Introduces tests package marker for discovery/import behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +15
config_dir = root / "configs"
config_dir.mkdir(exist_ok=True)
(config_dir / "config.ini").write_text(
"[DEFAULT]\n"
"base_url=https://gitlab.example\n"
Comment on lines +24 to +27
(config_dir / "templates.json").write_text(
'{"templates": [], "reviewers": []}',
encoding="utf-8",
)
Comment on lines +35 to +39
sys.modules["inquirer"] = inquirer_stub

spec = importlib.util.spec_from_file_location("gitHappens_under_test", root / "gitHappens.py")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
Comment on lines +43 to +46
class AutoFetchAfterMergeRequestTest(unittest.TestCase):
def test_fetches_origin_after_merge_request_when_setting_is_enabled(self):
git_happens = load_githappens_module(auto_fetch_after_merge_request=True)
created_issue = {"iid": 12, "title": "Fix broken thing"}
Comment thread gitHappens.py Outdated
Comment on lines 342 to 344

print("Run:")
print(" git fetch origin")
@subhajitlucky
Copy link
Copy Markdown
Author

Updated this PR to address the review comments:

  • preserves/restores existing local config fixture files during tests
  • scopes the inquirer stub with mock.patch.dict
  • adds coverage for auto_fetch_after_merge_request=false
  • omits the redundant git fetch origin instruction when the fetch already ran automatically

Verification after the update:

  • python3 -m unittest tests.test_auto_fetch_after_merge_request -v
  • python3 -m unittest discover -v
  • python3 -m compileall gitHappens.py tests
  • git diff --check

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.

Add setting to auto git fetch after merge request is created

2 participants