[damned-lies] Fixes #273 - Use real main branch name in various strings/messages
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fixes #273 - Use real main branch name in various strings/messages
- Date: Sun, 2 Jan 2022 21:06:22 +0000 (UTC)
commit 68ec53e7e4bf90e1d44dfac37b4739934dcb9674
Author: Claude Paroz <claude 2xlibre net>
Date: Sun Jan 2 22:05:04 2022 +0100
Fixes #273 - Use real main branch name in various strings/messages
Thanks Tim Sabsch for the report.
stats/models.py | 2 +-
vertimus/forms.py | 12 +++++++-----
vertimus/models.py | 12 ++++++++----
vertimus/tests/tests.py | 5 +++++
4 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index e95cdb93..6fe7b236 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -643,7 +643,7 @@ class Branch(models.Model):
def cherrypick_commit(self, commit_hash, domain):
"""
- Try to cherry-pick a branch commit `commit_hash` into master.
+ Try to cherry-pick a branch commit `commit_hash` into main branch.
Return True if the cherry-pick succeeds, False otherwise.
"""
with ModuleLock(self.module):
diff --git a/vertimus/forms.py b/vertimus/forms.py
index 2f98fb79..97c7438b 100644
--- a/vertimus/forms.py
+++ b/vertimus/forms.py
@@ -50,11 +50,7 @@ class ActionForm(forms.Form):
widget=forms.Textarea(attrs={'rows': 8, 'cols': 70, 'class': 'form-control'})
)
author = AuthorChoiceField(label=_("Commit author"), queryset=Person.objects.none(), required=False)
- sync_master = forms.BooleanField(
- label=_("Sync with master"),
- help_text=_("Try to cherry-pick the commit to the master branch"),
- required=False
- )
+ sync_master = forms.BooleanField(required=False)
file = forms.FileField(label=_("File"), required=False,
help_text=_("Upload a .po, .gz, .bz2, .xz or .png file"))
send_to_ml = forms.BooleanField(label=_("Send message to the team mailing list"), required=False)
@@ -77,6 +73,12 @@ class ActionForm(forms.Form):
del self.fields['send_to_ml']
if state and state.branch.is_head():
del self.fields['sync_master']
+ elif state:
+ main_branch = state.branch.module.get_head_branch()
+ self.fields['sync_master'].label = _("Sync with %(name)s") % {'name': main_branch.name}
+ self.fields['sync_master'].help_text = (
+ _("Try to cherry-pick the commit to the %(name)s branch") % {'name': main_branch.name}
+ )
def clean_file(self):
data = self.cleaned_data['file']
diff --git a/vertimus/models.py b/vertimus/models.py
index b6cdb00f..a10ae7c4 100644
--- a/vertimus/models.py
+++ b/vertimus/models.py
@@ -701,12 +701,16 @@ class ActionCI(Action):
msg = gettext("The file has been successfully committed to the repository.")
if form_data.get('sync_master', False) and not state.branch.is_head():
# Cherry-pick the commit on the master branch
- success = state.branch.module.get_head_branch().cherrypick_commit(commit_hash, state.domain)
+ main_branch = state.branch.module.get_head_branch()
+ success = main_branch.cherrypick_commit(commit_hash, state.domain)
if success:
- msg += gettext(" Additionally, the synchronization with the master branch succeeded.")
+ msg += gettext(" Additionally, the synchronization with the %(name)s branch succeeded.") % {
+ 'name': main_branch.name
+ }
else:
- msg += gettext(" However, the synchronization with the master branch failed.")
-
+ msg += gettext(" However, the synchronization with the %(name)s branch failed.") % {
+ 'name': main_branch.name
+ }
super().apply_on(state, form_data) # Mail sent in super
return msg
diff --git a/vertimus/tests/tests.py b/vertimus/tests/tests.py
index 74c4ec43..b08fc7ad 100644
--- a/vertimus/tests/tests.py
+++ b/vertimus/tests/tests.py
@@ -426,6 +426,9 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
# Setup as a writable repo
self.b.module.vcs_root = 'git gitlab gnome org:GNOME/%s.git' % self.b.module.name
self.b.module.save()
+ Branch.checkout_on_creation = False
+ master = Branch(name='master', module=self.m)
+ master.save(update_statistics=False)
state = StateProofreading(branch=self.b, domain=self.d, language=self.language, person=self.pr)
state.save()
@@ -446,6 +449,8 @@ class VertimusTest(TeamsAndRolesMixin, TestCase):
form = ActionForm(self.pcoo, state, state.get_available_actions(self.pcoo), True)
self.assertEqual(len(form.fields['author'].choices), 6)
self.assertEqual(form.fields['author'].initial, self.pr)
+ self.assertIn('sync_master', form.fields)
+ self.assertEqual(form.fields['sync_master'].label, "Sync with master")
self.assertHTMLEqual(
str(form['author']),
'<select id="id_author" name="author">'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]