Skip to content

Conversation

@nijel
Copy link
Member

@nijel nijel commented Jan 7, 2026

Include both missing from upstream and missing from fork to count. This should avoid creating empty pull requests in some situations.

Fixes #17226

Copilot AI and others added 13 commits January 7, 2026 08:16
- Add get_fork_branch_name() helper to avoid code duplication
- Use super().count_outgoing() for origin check (looks at pull branch)
- Update push() to use the helper method
- Update test to use helper method for consistency

Co-authored-by: nijel <[email protected]>
- Add check for should_use_fork(branch) before fork checking
- Only check fork branch when fork is actually used for that branch
- Add test for non-default branch behavior
- Add comment explaining why branch parameter is omitted from super() call

Co-authored-by: nijel <[email protected]>
@nijel nijel added this to the 5.15.2 milestone Jan 7, 2026
@nijel nijel self-assigned this Jan 7, 2026
@nijel nijel requested a review from AliceVisek as a code owner January 7, 2026 13:02
@nijel nijel requested a review from Copilot January 7, 2026 13:02
Copy link
Contributor

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

This pull request improves the counting of outgoing commits in merge request workflows to prevent creating empty pull requests. The fix addresses issue #17226 by checking commits against both the upstream repository (origin) and the fork remote to accurately determine if there are commits that need to be pushed.

Key changes:

  • Extracts fork branch naming logic into a reusable method
  • Implements enhanced outgoing commit detection that checks both origin and fork remotes
  • Adds comprehensive test coverage for the new behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
weblate/vcs/git.py Adds get_fork_branch_name() method and overrides count_outgoing() to check both origin and fork remotes for pending commits
weblate/vcs/tests/test_vcs.py Adds two new test cases verifying the count_outgoing behavior after merge and with non-default branches
docs/changes.rst Documents the fix in the changelog under bug fixes

Comment on lines 900 to 901
# Omit branch to look at pull branch, not push branch
origin_outgoing = super().count_outgoing()
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

The branch parameter should be passed to the parent's count_outgoing() method. Currently, line 901 calls super().count_outgoing() without arguments, but the method signature accepts a branch parameter. This could lead to incorrect behavior when checking outgoing commits for a specific branch, as the parent method would use its default behavior instead of checking the requested branch.

Suggested change
# Omit branch to look at pull branch, not push branch
origin_outgoing = super().count_outgoing()
origin_outgoing = super().count_outgoing(branch)

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 94.33962% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.75%. Comparing base (2acf712) to head (df6d162).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
weblate/vcs/git.py 86.36% 1 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (94.33%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI and others added 7 commits January 7, 2026 17:05
- Move should_use_fork check to beginning of method
- Pass branch parameter to super() when not using fork
- Only omit branch parameter when using fork (to check pull branch)
- This ensures branch parameter is correctly respected

Co-authored-by: nijel <[email protected]>
- Wrap credentials access in try-except to catch KeyError
- This handles cases where credentials are not configured for the repository
- Prevents test failures when fork credentials are missing

Co-authored-by: nijel <[email protected]>
- Revert commit 35e3c0e that added KeyError handling
- Add setUp method to VCSGitLabTest to set repo URL to gitlab.com
- This ensures credentials are properly matched during tests
- Credentials were already configured via @override_settings decorator

Co-authored-by: nijel <[email protected]>
Copy link
Contributor

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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.

Weblate opens empty merge requests on GitLab since 5.14.3

1 participant