summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-08-27 17:14:54 +0200
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-08-27 17:19:11 +0200
commit8241f0706bdd8ea58200aebdcb814869591b16e7 (patch)
tree70cd312ace2e3ae67fac309071954a3ca74103b1
parent1eb9dae10ef971c76ff0593e0e68c8138983b336 (diff)
downloadvendor_replicant-scripts-8241f0706bdd8ea58200aebdcb814869591b16e7.tar.gz
vendor_replicant-scripts-8241f0706bdd8ea58200aebdcb814869591b16e7.tar.bz2
vendor_replicant-scripts-8241f0706bdd8ea58200aebdcb814869591b16e7.zip
replicant_prepare_patch: cover text: Handle plural due to multiple patches
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@cyberdimension.org>
-rwxr-xr-xpatches/replicant_prepare_patch.py23
1 files 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)))