diff options
author | Jan Durovec <jan.durovec@gmail.com> | 2016-04-19 19:49:41 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-19 13:41:00 -0700 |
commit | 26e6a27d6965c9c5ee4f59ae9a97cef893b52686 (patch) | |
tree | 344a17b938461d9e8bfd85475ba8d0759f45b035 /git-p4.py | |
parent | git-p4: clean-up code style in tests (diff) | |
download | git-26e6a27d6965c9c5ee4f59ae9a97cef893b52686.tar.xz git-26e6a27d6965c9c5ee4f59ae9a97cef893b52686.zip |
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-x | git-p4.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/git-p4.py b/git-p4.py index 527d44bd202..8f869d74a11 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: |