aboutsummaryrefslogtreecommitdiff
path: root/git-p4.py
diff options
context:
space:
mode:
authorJan Durovec <jan.durovec@gmail.com>2016-04-19 19:49:41 +0000
committerJunio C Hamano <gitster@pobox.com>2016-04-19 13:41:00 -0700
commit26e6a27d6965c9c5ee4f59ae9a97cef893b52686 (patch)
tree344a17b938461d9e8bfd85475ba8d0759f45b035 /git-p4.py
parenta98772c63fa666e9239b0cdbd790daf7af503b75 (diff)
downloadgit-26e6a27d6965c9c5ee4f59ae9a97cef893b52686.tar.gz
git-26e6a27d6965c9c5ee4f59ae9a97cef893b52686.tar.xz
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>
Diffstat (limited to 'git-p4.py')
-rwxr-xr-xgit-p4.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/git-p4.py b/git-p4.py
index 527d44bd2..8f869d74a 100755
--- a/git-p4.py
+++ b/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: