Handle missing active milestones#152
Open
subhajitlucky wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent failures when a GitLab group has no “active for today” milestones by returning None from milestone auto-selection, and adds a regression test for the empty active-milestones case (Fixes #47).
Changes:
- Update
list_milestones(current=True)to returnNonewhen no active milestone matches the current date window. - Add a unit test covering the empty “active-for-today” milestone scenario.
- Add
tests/__init__.pyto maketestsa package.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
gitHappens.py |
Returns None when no current active milestone is found (and includes a minor EOF formatting change). |
tests/test_milestones_empty.py |
Adds regression coverage for the empty current-milestone case via a dynamic module load and subprocess mocking. |
tests/__init__.py |
Introduces a package marker for the tests directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
102
to
107
| if start_date and due_date and start_date <= today and due_date >= today: | ||
| active_milestones.append(milestone) | ||
| active_milestones.sort(key=lambda x: x['due_date']) | ||
| if not active_milestones: | ||
| return None | ||
| return active_milestones[0] |
Comment on lines
104
to
+106
| active_milestones.sort(key=lambda x: x['due_date']) | ||
| if not active_milestones: | ||
| return None |
Comment on lines
+11
to
+27
| root = Path(__file__).resolve().parents[1] | ||
| config_dir = root / "configs" | ||
| config_dir.mkdir(exist_ok=True) | ||
| (config_dir / "config.ini").write_text( | ||
| "[DEFAULT]\n" | ||
| "base_url=https://gitlab.example\n" | ||
| "group_id=42\n" | ||
| "custom_template=Custom\n" | ||
| "GITLAB_TOKEN=test-token\n" | ||
| "squash_commits=true\n" | ||
| "delete_branch_after_merge=true\n", | ||
| encoding="utf-8", | ||
| ) | ||
| (config_dir / "templates.json").write_text( | ||
| '{"templates": [], "reviewers": []}', | ||
| encoding="utf-8", | ||
| ) |
Comment on lines
+29
to
+38
| sys.modules["inquirer"] = types.SimpleNamespace( | ||
| prompt=mock.Mock(), | ||
| Text=lambda *args, **kwargs: ("Text", args, kwargs), | ||
| List=lambda *args, **kwargs: ("List", args, kwargs), | ||
| Checkbox=lambda *args, **kwargs: ("Checkbox", args, kwargs), | ||
| ) | ||
|
|
||
| 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) |
Author
|
Updated this PR to address the review comments:
Verification after the update:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #47
Summary
Nonewhen the GitLab project has no active milestones during manual milestone selectionVerification
python3 -m unittest tests.test_milestones_empty -vpython3 -m unittest discover -vpython3 -m compileall gitHappens.py testsgit diff --check