55import itertools
66import os
77import re
8+ import sys
89
910from rdopkg .conf import cfg , cfg_files
1011from rdopkg import exception
@@ -677,12 +678,20 @@ def new_sources(branch=None, fedpkg=FEDPKG, new_sources=False):
677678 run (* cmd , direct = True )
678679
679680
680- def _commit_message (changes = None ):
681+ def _commit_message (changes = None , header_file = None ):
681682 if not changes :
682683 _ , changes = specfile .Spec ().get_last_changelog_entry (strip = True )
683684 if not changes :
684685 raise exception .IncompleteChangelog ()
685- if len (changes ) == 1 :
686+ if header_file :
687+ try :
688+ if header_file == '-' :
689+ msg = sys .stdin .read ()
690+ else :
691+ msg = open (header_file ).read ()
692+ except IOError as ex :
693+ raise exception .FileNotFound (msg = str (ex ))
694+ elif len (changes ) == 1 :
686695 msg = re .sub (r'\s+\(.*\)\s*$' , '' , changes [0 ])
687696 else :
688697 msg = specfile .Spec ().get_nvr (epoch = False )
@@ -700,17 +709,17 @@ def _commit_message(changes=None):
700709 return msg
701710
702711
703- def commit_distgit_update (branch = None , amend = False ):
712+ def commit_distgit_update (branch = None , amend = False , commit_header_file = None ):
704713 _ensure_branch (branch )
705- msg = _commit_message ()
714+ msg = _commit_message (header_file = commit_header_file )
706715 cmd = ['commit' , '-a' , '-F' , '-' ]
707716 if amend :
708717 cmd .append ('--amend' )
709718 git (* cmd , input = msg , print_output = True )
710719
711720
712- def amend ():
713- msg = _commit_message ()
721+ def amend (commit_header_file = None ):
722+ msg = _commit_message (header_file = commit_header_file )
714723 git ('commit' , '-a' , '--amend' , '-F' , '-' , input = msg , print_output = True )
715724 print ("" )
716725 git ('--no-pager' , 'log' , '--name-status' , 'HEAD~..HEAD' , direct = True )
0 commit comments