git-p4: add P4 jobs to git commit message
When migrating from Perforce to git the information about P4 jobs associated with P4 changelists is lost. Having these jobs listed on messages of related git commits enables smooth migration for projects that take advantage of e.g. JIRA integration (which uses jobs on Perforce side and parses commit messages on git side). The jobs are added to the message in the same format as is expected when migrating in the reverse direction. Signed-off-by: Jan Durovec <jan.durovec@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
a98772c63f
commit
26e6a27d69
12
git-p4.py
12
git-p4.py
@ -2320,6 +2320,15 @@ class P4Sync(Command, P4UserMap):
|
||||
fnum = fnum + 1
|
||||
return files
|
||||
|
||||
def extractJobsFromCommit(self, commit):
|
||||
jobs = []
|
||||
jnum = 0
|
||||
while commit.has_key("job%s" % jnum):
|
||||
job = commit["job%s" % jnum]
|
||||
jobs.append(job)
|
||||
jnum = jnum + 1
|
||||
return jobs
|
||||
|
||||
def stripRepoPath(self, path, prefixes):
|
||||
"""When streaming files, this is called to map a p4 depot path
|
||||
to where it should go in git. The prefixes are either
|
||||
@ -2665,6 +2674,7 @@ class P4Sync(Command, P4UserMap):
|
||||
def commit(self, details, files, branch, parent = ""):
|
||||
epoch = details["time"]
|
||||
author = details["user"]
|
||||
jobs = self.extractJobsFromCommit(details)
|
||||
|
||||
if self.verbose:
|
||||
print('commit into {0}'.format(branch))
|
||||
@ -2692,6 +2702,8 @@ class P4Sync(Command, P4UserMap):
|
||||
|
||||
self.gitStream.write("data <<EOT\n")
|
||||
self.gitStream.write(details["desc"])
|
||||
if len(jobs) > 0:
|
||||
self.gitStream.write("\nJobs: %s" % (' '.join(jobs)))
|
||||
self.gitStream.write("\n[git-p4: depot-paths = \"%s\": change = %s" %
|
||||
(','.join(self.branchPrefixes), details["change"]))
|
||||
if len(details['options']) > 0:
|
||||
|
||||
Reference in New Issue
Block a user