git-p4: fix skipSubmitEdit regression
Commit 7c766e5 (git-p4: introduce skipSubmitEdit, 2011-12-04) made it easier to automate submission to p4, but broke the most common case. Add a test for when the user really does edit and save the change template, and fix the bug that causes the test to fail. Also add a confirmation message when submission is cancelled. Reported-by: Michael Horowitz <michael.horowitz@ieee.org> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
ee22802493
commit
d16520499d
@ -872,7 +872,10 @@ class P4Submit(Command, P4UserMap):
|
|||||||
if gitConfig("git-p4.skipSubmitEditCheck") == "true":
|
if gitConfig("git-p4.skipSubmitEditCheck") == "true":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
if os.stat(template_file).st_mtime <= mtime:
|
# modification time updated means user saved the file
|
||||||
|
if os.stat(template_file).st_mtime > mtime:
|
||||||
|
return True
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
|
response = raw_input("Submit template unchanged. Submit anyway? [y]es, [n]o (skip this patch) ")
|
||||||
if response == 'y':
|
if response == 'y':
|
||||||
@ -1062,6 +1065,7 @@ class P4Submit(Command, P4UserMap):
|
|||||||
self.modifyChangelistUser(changelist, p4User)
|
self.modifyChangelistUser(changelist, p4User)
|
||||||
else:
|
else:
|
||||||
# skip this patch
|
# skip this patch
|
||||||
|
print "Submission cancelled, undoing p4 changes."
|
||||||
for f in editedFiles:
|
for f in editedFiles:
|
||||||
p4_revert(f)
|
p4_revert(f)
|
||||||
for f in filesToAdd:
|
for f in filesToAdd:
|
||||||
|
@ -38,7 +38,7 @@ test_expect_success 'no config, unedited, say no' '
|
|||||||
cd "$git" &&
|
cd "$git" &&
|
||||||
echo line >>file1 &&
|
echo line >>file1 &&
|
||||||
git commit -a -m "change 3 (not really)" &&
|
git commit -a -m "change 3 (not really)" &&
|
||||||
printf "bad response\nn\n" | "$GITP4" submit
|
printf "bad response\nn\n" | "$GITP4" submit &&
|
||||||
p4 changes //depot/... >wc &&
|
p4 changes //depot/... >wc &&
|
||||||
test_line_count = 2 wc
|
test_line_count = 2 wc
|
||||||
)
|
)
|
||||||
@ -74,6 +74,28 @@ test_expect_success 'skipSubmitEditCheck' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
# check the normal case, where the template really is edited
|
||||||
|
test_expect_success 'no config, edited' '
|
||||||
|
"$GITP4" clone --dest="$git" //depot &&
|
||||||
|
test_when_finished cleanup_git &&
|
||||||
|
ed="$TRASH_DIRECTORY/ed.sh" &&
|
||||||
|
test_when_finished "rm \"$ed\"" &&
|
||||||
|
cat >"$ed" <<-EOF &&
|
||||||
|
#!$SHELL_PATH
|
||||||
|
sleep 1
|
||||||
|
touch "\$1"
|
||||||
|
exit 0
|
||||||
|
EOF
|
||||||
|
chmod 755 "$ed" &&
|
||||||
|
(
|
||||||
|
cd "$git" &&
|
||||||
|
echo line >>file1 &&
|
||||||
|
git commit -a -m "change 5" &&
|
||||||
|
EDITOR="\"$ed\"" "$GITP4" submit &&
|
||||||
|
p4 changes //depot/... >wc &&
|
||||||
|
test_line_count = 5 wc
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'kill p4d' '
|
test_expect_success 'kill p4d' '
|
||||||
kill_p4d
|
kill_p4d
|
||||||
|
Loading…
x
Reference in New Issue
Block a user