Skip to content
This repository has been archived by the owner on Jan 22, 2018. It is now read-only.

add --dry-run option to 'p4 submit' #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,8 @@ class P4Submit(Command):
Command.__init__(self)
self.options = [
optparse.make_option("--verbose", dest="verbose", action="store_true"),
optparse.make_option("--dry-run", dest="dryRun", action="store_true"),
optparse.make_option("--no-squash", dest="noSquash", action="store_true"),
optparse.make_option("--origin", dest="origin"),
optparse.make_option("--auto", dest="interactive", action="store_false", help="Automatically submit changelists without requiring editing"),
optparse.make_option("-M", dest="detectRename", action="store_true", help="detect renames"),
Expand All @@ -829,6 +831,8 @@ class P4Submit(Command):
if gitConfig("git-p4.detectCopy") == "true":
self.detectCopy = True
self.verbose = False
self.dryRun = False
self.noSquash = False
self.isWindows = (platform.system() == "Windows")
self.importIntoRemotes = True
if gitConfig("git-p4.importIntoRemotes") == "false":
Expand Down Expand Up @@ -1152,13 +1156,20 @@ class P4Submit(Command):
self.check()

self.commits = []
for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
revListOption = "--no-merges" if self.noSquash else "--first-parent"
for line in read_pipe_lines("git rev-list %s %s..%s" % (revListOption, self.origin, self.master)):
self.commits.append(line.strip())
self.commits.reverse()

if self.verbose:
print "Commits to apply: %s" % self.commits

if self.dryRun:
print "Would submit"
for commit in self.commits:
print (read_pipe("git log --max-count=1 --pretty=oneline %s" % commit))
return True

self.applyCommits()

if self.abort == False:
Expand Down