[PATCH] git/hooks: only use first line as project description

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If a description file contains multiple lines the script reads the whole
file and uses them in the X-Project: header.  This leaves subsequent
headers in the message body.

Here's an example from this repository:

    Subject: [ansible] Redefine master_repomd settings that don't have defaults.
    Keywords: ansible
    X-Project: ansible playbook/files/etc repository for fedora infrastructure.
    Message-Id: <20180209174002.696C8FB72586@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
    Date: Fri,  9 Feb 2018 17:40:02 +0000 (UTC)

    This is the public repository, do not commit sensitive
    or confidential information here.
    X-Git-Refname: refs/heads/master
    X-Git-Oldrev: db817ee0f3bbd99b762a2d6b78d84212a0770935
    X-Git-Newrev: d65b46a20984939465a6209205662f0030d80f54

    commit d65b46a20984939465a6209205662f0030d80f54

A further potential feature could be added to include the additional lines
from the description file in the beginning of the message body, if they
are desired.
---
Hi all,

This is something I've seen for ages and thought should be fixed (either by
this patch and/or another which supports multi-line description files
properly).

I have an alternate version of this patch which side-steps the issue by adding
the X-Project header last, so if it's multiple lines it won't screw up other
headers.  I think this is the proper fix though.

If multi-line description files are really something which are desired, then a
commit on top of this change could add support for reading the remaining lines
from the description file and add them to the message body.

 roles/git/hooks/files/git.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/roles/git/hooks/files/git.py b/roles/git/hooks/files/git.py
index 72adff1f7..586fbffd2 100644
--- a/roles/git/hooks/files/git.py
+++ b/roles/git/hooks/files/git.py
@@ -202,7 +202,8 @@ def get_project_description():
     description = os.path.join(git_dir, 'description')
     if os.path.exists(description):
         try:
-            projectdesc = open(description).read().strip()
+            with open(description, 'r') as f:
+                projectdesc = f.readline().strip()
         except:
             pass
     if projectdesc.startswith('Unnamed repository;'):
-- 
2.16.2
_______________________________________________
infrastructure mailing list -- infrastructure@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to infrastructure-leave@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux