[Replicant] [vendor_replicant-scripts] [PATCH 2/2] replicant_prepare_patch: cover text: Handle plural due to multiple patches
Denis 'GNUtoo' Carikli
GNUtoo at cyberdimension.org
Thu Aug 27 15:20:43 UTC 2020
If there is more than one patch, the generated text will look strange if
left as-is, as it assume that only one patch is sent.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
patches/replicant_prepare_patch.py | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/patches/replicant_prepare_patch.py b/patches/replicant_prepare_patch.py
index a8d2d3f..079b4a2 100755
--- a/patches/replicant_prepare_patch.py
+++ b/patches/replicant_prepare_patch.py
@@ -23,11 +23,11 @@ from sh import echo, git
# Settings
cover_mail_template = """Hi,
-In addition to the patch that will follow in a response to
-this mail, here's an URL to the see the patch in a web interface:
+In addition to the {patch} that will follow in a response to
+this mail, here's an URL to the see the {patch} in a web interface:
{web_url}
-And here's how to get it in a git repository:
+And here's how to get {it} in a git repository:
git clone {clone_repo}
cd {repo_name}
git show {commit}
@@ -152,7 +152,7 @@ def generate_patches(config, git_revision, nr_patches, patches_revision):
return patches
-def generate_cover_mail_text(config, commit, repo):
+def generate_cover_mail_text(config, commit, nr_patches, repo):
cgit_url = 'https://git.replicant.us'
web_url = '{base}/contrib/{user}/{repo}/commit/?id={commit}'.format(
@@ -164,13 +164,20 @@ def generate_cover_mail_text(config, commit, repo):
signature = config['local']['mail_signature']
- return cover_mail_template.format(web_url=web_url,
+ patch = 'patch'
+ it = 'it'
+ if nr_patches > 1:
+ patch = 'patches'
+ it = 'them'
+
+ return cover_mail_template.format(patch=patch,
+ it=it,
+ web_url=web_url,
clone_repo=clone_repo,
commit=commit,
repo_name=repo,
signature=signature)
-
def generate_git_send_email_command(config, git_revision, patches):
command = ['send-email',
'--compose',
@@ -197,7 +204,7 @@ if __name__ == '__main__':
usage(sys.argv[0])
if len (sys.argv) >= 3:
- nr_patches = sys.argv[2]
+ nr_patches = int(sys.argv[2])
if len (sys.argv) >= 4:
patches_revision = sys.argv[3]
@@ -228,4 +235,4 @@ if __name__ == '__main__':
print()
print('Cover mail:')
print('-----------')
- print(generate_cover_mail_text(config, git_revision, get_repo_name(config)))
+ print(generate_cover_mail_text(config, git_revision, nr_patches, get_repo_name(config)))
--
2.28.0
More information about the Replicant
mailing list