1
0
mirror of https://github.com/git/git.git synced 2024-09-28 04:10:41 +02:00

git-p4: Clean up git-p4 submit's log message handling.

Instead of trying to substitute fields in the p4 submit template we now simply
replace the description of the submit with the log message of the git commit.

Signed-off-by: Simon Hausmann <simon@lst.de>
This commit is contained in:
Simon Hausmann 2008-02-19 09:29:06 +01:00
parent 4b61b5c963
commit edae1e2f40

View File

@ -483,10 +483,6 @@ class P4Submit(Command):
self.verbose = False self.verbose = False
self.isWindows = (platform.system() == "Windows") self.isWindows = (platform.system() == "Windows")
self.logSubstitutions = {}
self.logSubstitutions["<enter description here>"] = "%log%"
self.logSubstitutions["\tDetails:"] = "\tDetails: %log%"
def check(self): def check(self):
if len(p4CmdList("opened ...")) > 0: if len(p4CmdList("opened ...")) > 0:
die("You have files opened with perforce! Close them before starting the sync.") die("You have files opened with perforce! Close them before starting the sync.")
@ -507,26 +503,31 @@ class P4Submit(Command):
self.config["commits"] = commits self.config["commits"] = commits
# replaces everything between 'Description:' and the next P4 submit template field with the
# commit message
def prepareLogMessage(self, template, message): def prepareLogMessage(self, template, message):
result = "" result = ""
inDescriptionSection = False
for line in template.split("\n"): for line in template.split("\n"):
if line.startswith("#"): if line.startswith("#"):
result += line + "\n" result += line + "\n"
continue continue
substituted = False if inDescriptionSection:
for key in self.logSubstitutions.keys(): if line.startswith("Files:"):
if line.find(key) != -1: inDescriptionSection = False
value = self.logSubstitutions[key] else:
value = value.replace("%log%", message) continue
if value != "@remove@": else:
result += line.replace(key, value) + "\n" if line.startswith("Description:"):
substituted = True inDescriptionSection = True
break line += "\n"
for messageLine in message.split("\n"):
line += "\t" + messageLine + "\n"
if not substituted: result += line + "\n"
result += line + "\n"
return result return result
@ -650,7 +651,6 @@ class P4Submit(Command):
logMessage = "" logMessage = ""
if not self.directSubmit: if not self.directSubmit:
logMessage = extractLogMessageFromGitCommit(id) logMessage = extractLogMessageFromGitCommit(id)
logMessage = logMessage.replace("\n", "\n\t")
if self.isWindows: if self.isWindows:
logMessage = logMessage.replace("\n", "\r\n") logMessage = logMessage.replace("\n", "\r\n")
logMessage = logMessage.strip() logMessage = logMessage.strip()