-
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix fast-forwarding, test --rebase 0
- Loading branch information
Showing
16 changed files
with
665 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
integration-tests/rebase-zero/__snapshots__/rebase-zero.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Test rebase-zero: 00: rebase to zero 1`] = ` | ||
"SNAPSHOT: rebase to zero | ||
patch-package 0.0.0 | ||
Un-applied left-pad+1.3.0+003+goodbye.patch | ||
Un-applied left-pad+1.3.0+002+world.patch | ||
Un-applied left-pad+1.3.0+001+hello.patch | ||
Make any changes you need inside node_modules/left-pad | ||
When you are done, run | ||
patch-package left-pad --append 'MyChangeDescription' | ||
to insert a new patch file. | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test rebase-zero: 01: it creates a new patch at the start and renames all the other patches, applying them 1`] = ` | ||
"SNAPSHOT: it creates a new patch at the start and renames all the other patches, applying them | ||
patch-package 0.0.0 | ||
β’ Creating temporary folder | ||
β’ Installing left-pad@1.3.0 with npm | ||
β’ Diffing your files with clean files | ||
β Created file patches/left-pad+1.3.0+001+WhileOne.patch | ||
Renaming left-pad+1.3.0+001+hello.patch to left-pad+1.3.0+002+hello.patch | ||
Renaming left-pad+1.3.0+002+world.patch to left-pad+1.3.0+003+world.patch | ||
Renaming left-pad+1.3.0+003+goodbye.patch to left-pad+1.3.0+004+goodbye.patch | ||
Fast forwarding... | ||
β left-pad+1.3.0+002+hello.patch | ||
β left-pad+1.3.0+003+world.patch | ||
β left-pad+1.3.0+004+goodbye.patch | ||
left-pad+1.3.0+001+WhileOne.patch | ||
left-pad+1.3.0+002+hello.patch | ||
left-pad+1.3.0+003+world.patch | ||
left-pad+1.3.0+004+goodbye.patch | ||
the state file | ||
{ | ||
\\"isRebasing\\": false, | ||
\\"patches\\": [ | ||
{ | ||
\\"didApply\\": true, | ||
\\"patchContentHash\\": \\"dfc6e6951dc7d5bf2e1768a353933c73ba6bccd76c7927d28384107f3be2e8eb\\", | ||
\\"patchFilename\\": \\"left-pad+1.3.0+001+WhileOne.patch\\" | ||
}, | ||
{ | ||
\\"didApply\\": true, | ||
\\"patchContentHash\\": \\"404c604ed830db6a0605f86cb9165ced136848f70986b23bf877bcf38968c1c9\\", | ||
\\"patchFilename\\": \\"left-pad+1.3.0+002+hello.patch\\" | ||
}, | ||
{ | ||
\\"didApply\\": true, | ||
\\"patchContentHash\\": \\"f2859c7193de8d9578bdde7e226de516adc8d972d6e76997cbe1f41b1a535359\\", | ||
\\"patchFilename\\": \\"left-pad+1.3.0+003+world.patch\\" | ||
}, | ||
{ | ||
\\"didApply\\": true, | ||
\\"patchContentHash\\": \\"c9063ed6ae00867ee243fa71590c369ce0bb699f3a63a10df86d3ec988782715\\", | ||
\\"patchFilename\\": \\"left-pad+1.3.0+004+goodbye.patch\\" | ||
} | ||
], | ||
\\"version\\": 1 | ||
}the js file | ||
/* This program is free software. It comes without any warranty, to | ||
* the extent permitted by applicable law. You can redistribute it | ||
* and/or modify it under the terms of the Do What The Fuck You Want | ||
* To Public License, Version 2, as published by Sam Hocevar. See | ||
* http://www.wtfpl.net/ for more details. */ | ||
'goodbye world'; | ||
module.exports = leftPad; | ||
var cache = [ | ||
'', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ', | ||
' ' | ||
]; | ||
function leftPad (str, len, ch) { | ||
// convert \`str\` to a \`string\` | ||
str = str + ''; | ||
// \`len\` is the \`pad\`'s length now | ||
len = len - str.length; | ||
// doesn't need to pad | ||
if (len <= 0) return str; | ||
// \`ch\` defaults to \`' '\` | ||
if (!ch && ch !== 0) ch = ' '; | ||
// convert \`ch\` to a \`string\` cuz it could be a number | ||
ch = ch + ''; | ||
// cache common use cases | ||
if (ch === ' ' && len < 10) return cache[len] + str; | ||
// \`pad\` starts with an empty string | ||
var pad = ''; | ||
// loop | ||
while (1) { | ||
// add \`ch\` to \`pad\` if \`len\` is odd | ||
if (len & 1) pad += ch; | ||
// divide \`len\` by 2, ditch the remainder | ||
len >>= 1; | ||
// \\"double\\" the \`ch\` so this operation count grows logarithmically on \`len\` | ||
// each time \`ch\` is \\"doubled\\", the \`len\` would need to be \\"doubled\\" too | ||
// similar to finding a value in binary search tree, hence O(log(n)) | ||
if (len) ch += ch; | ||
// \`len\` is 0, exit the loop | ||
else break; | ||
} | ||
// pad \`str\`! | ||
return pad + str; | ||
} | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test rebase-zero: 02: rebase to zero again 1`] = ` | ||
"SNAPSHOT: rebase to zero again | ||
patch-package 0.0.0 | ||
Un-applied left-pad+1.3.0+004+goodbye.patch | ||
Un-applied left-pad+1.3.0+003+world.patch | ||
Un-applied left-pad+1.3.0+002+hello.patch | ||
Un-applied left-pad+1.3.0+001+WhileOne.patch | ||
Make any changes you need inside node_modules/left-pad | ||
When you are done, run | ||
patch-package left-pad --append 'MyChangeDescription' | ||
to insert a new patch file. | ||
END SNAPSHOT" | ||
`; | ||
|
||
exports[`Test rebase-zero: 03: it creates a new patch at the start called 'initial' if you dont do --append 1`] = ` | ||
"SNAPSHOT: it creates a new patch at the start called 'initial' if you dont do --append | ||
patch-package 0.0.0 | ||
β’ Creating temporary folder | ||
β’ Installing left-pad@1.3.0 with npm | ||
β’ Diffing your files with clean files | ||
β Created file patches/left-pad+1.3.0+001+initial.patch | ||
Renaming left-pad+1.3.0+001+WhileOne.patch to left-pad+1.3.0+002+WhileOne.patch | ||
Renaming left-pad+1.3.0+002+hello.patch to left-pad+1.3.0+003+hello.patch | ||
Renaming left-pad+1.3.0+003+world.patch to left-pad+1.3.0+004+world.patch | ||
Renaming left-pad+1.3.0+004+goodbye.patch to left-pad+1.3.0+005+goodbye.patch | ||
Fast forwarding... | ||
β left-pad+1.3.0+002+WhileOne.patch | ||
β left-pad+1.3.0+003+hello.patch | ||
β left-pad+1.3.0+004+world.patch | ||
β left-pad+1.3.0+005+goodbye.patch | ||
left-pad+1.3.0+001+initial.patch | ||
left-pad+1.3.0+002+WhileOne.patch | ||
left-pad+1.3.0+003+hello.patch | ||
left-pad+1.3.0+004+world.patch | ||
left-pad+1.3.0+005+goodbye.patch | ||
END SNAPSHOT" | ||
`; |
Oops, something went wrong.