Cover rename and deleted directory cases
This commit is contained in:
parent
f4b31356df
commit
9b4c18e8dc
@ -30,7 +30,7 @@ argParser.addArgument([ "-f", "--full" ], {
|
|||||||
});
|
});
|
||||||
argParser.addArgument([ "-i", "--incremental" ], {
|
argParser.addArgument([ "-i", "--incremental" ], {
|
||||||
type: isFile, nargs: 2, dest: "incrementalArgs",
|
type: isFile, nargs: 2, dest: "incrementalArgs",
|
||||||
metavar: ["<incremental zip file>", "<file containing list of deleted files>"]
|
metavar: ["<incremental zip file>", "<file containing list of changed files>"]
|
||||||
});
|
});
|
||||||
argParser.addArgument([ "-e", "--executable" ], {
|
argParser.addArgument([ "-e", "--executable" ], {
|
||||||
metavar: "[executable file]", nargs: 1,
|
metavar: "[executable file]", nargs: 1,
|
||||||
@ -45,7 +45,7 @@ const {
|
|||||||
executableArgs
|
executableArgs
|
||||||
} = argParser.parseArgs();
|
} = argParser.parseArgs();
|
||||||
|
|
||||||
const [incrementalZipFile, deletionsFile] = incrementalArgs || [];
|
const [incrementalZipFile, changesFile] = incrementalArgs || [];
|
||||||
const [fullZipFile] = fullZipFileArgs || [];
|
const [fullZipFile] = fullZipFileArgs || [];
|
||||||
const [executable] = executableArgs || [];
|
const [executable] = executableArgs || [];
|
||||||
|
|
||||||
@ -55,17 +55,56 @@ if (!incrementalZipFile && !fullZipFile) {
|
|||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do a quick litmus test to prevent deleting everything incorrectly
|
||||||
|
if (changesFile && !fs.existsSync("base")) {
|
||||||
|
console.error("The working directory must be set to an " +
|
||||||
|
"asset folder in order for deleted directories " +
|
||||||
|
"to be calculated correctly. Abort.");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
const manifest = JSON.parse(fs.readFileSync(manifestFile));
|
const manifest = JSON.parse(fs.readFileSync(manifestFile));
|
||||||
|
|
||||||
const deleteActions = deletionsFile ? fs.readFileSync(deletionsFile)
|
const dirsDeleted = new Set();
|
||||||
|
const specialActions = changesFile ?
|
||||||
|
fs.readFileSync(changesFile)
|
||||||
.toString()
|
.toString()
|
||||||
.trim()
|
.trim()
|
||||||
.split("\n").map(file => {
|
.split("\n")
|
||||||
// XXX: This does not delete empty directories. Finding them would
|
.map(line => line.split("\t"))
|
||||||
// actually be a substantial amount of work because Git does not
|
.map(([mode, target, source]) => {
|
||||||
// give us a good way of finding directories that were deleted.
|
switch (mode[0]) {
|
||||||
return { action: "delete", target: file };
|
case "D": // Deleted
|
||||||
}) : [];
|
// Check if the folder exists relative to the working
|
||||||
|
// directory, and if not, add it to the dirsDeleted list.
|
||||||
|
// Keep going up the tree to see how many directories were
|
||||||
|
// deleted.
|
||||||
|
let dir = path.dirname(target);
|
||||||
|
while (!dirsDeleted.has(dir) && !fs.existsSync(dir)) {
|
||||||
|
dirsDeleted.add(dir);
|
||||||
|
dir = path.dirname(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
return { action: "delete", target };
|
||||||
|
case "R": // Renamed
|
||||||
|
// NOTE: Make sure that the launcher's implementation of
|
||||||
|
// the move action also creates directories when needed.
|
||||||
|
return { action: "move", source, target};
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// Remove ignored file mode changes
|
||||||
|
.filter(action => action !== null)
|
||||||
|
// Create actions based on directories to be deleted.
|
||||||
|
// Always have deeper directories first, to guarantee that deleting
|
||||||
|
// higher-level directories will succeed.
|
||||||
|
+ Array.from(dirsDeleted.values())
|
||||||
|
.sort((a, b) => b.split("/").length - a.split("/").length)
|
||||||
|
.map(dir => {
|
||||||
|
return { action: "deleteDir", target: dir };
|
||||||
|
})
|
||||||
|
: [];
|
||||||
|
|
||||||
const urlBase = "https://s3.wasabisys.com/ao-downloads/";
|
const urlBase = "https://s3.wasabisys.com/ao-downloads/";
|
||||||
|
|
||||||
@ -83,7 +122,7 @@ const versionEntry = {
|
|||||||
}
|
}
|
||||||
] : undefined,
|
] : undefined,
|
||||||
update: incrementalArgs ? [
|
update: incrementalArgs ? [
|
||||||
...deleteActions,
|
...specialActions,
|
||||||
{
|
{
|
||||||
action: "dl",
|
action: "dl",
|
||||||
url: urlBase + encodeURIComponent(path.basename(incrementalZipFile)),
|
url: urlBase + encodeURIComponent(path.basename(incrementalZipFile)),
|
||||||
|
@ -36,16 +36,15 @@ echo "Current tagged version: ${VERSION}"
|
|||||||
if [[ -n $ARCHIVE_INCR && -n $LAST_TAGGED_VERSION ]]; then
|
if [[ -n $ARCHIVE_INCR && -n $LAST_TAGGED_VERSION ]]; then
|
||||||
echo "Incremental archive: ${ARCHIVE_INCR}"
|
echo "Incremental archive: ${ARCHIVE_INCR}"
|
||||||
|
|
||||||
# Get deleted files
|
# Get all files
|
||||||
export DELETIONS_FILE="deletions.txt"
|
export CHANGES_FILE="changes.txt"
|
||||||
git log --diff-filter=D --summary ${LAST_TAGGED_VERSION}..HEAD | \
|
git diff --summary ${LAST_TAGGED_VERSION}..HEAD > ${CHANGES_FILE}
|
||||||
grep "delete mode" | cut -d' ' -f 5- > ${DELETIONS_FILE}
|
|
||||||
|
|
||||||
# Get added/modified files
|
# Get added/modified files
|
||||||
git log --name-only --oneline --diff-filter=d ${LAST_TAGGED_VERSION}..HEAD | \
|
git diff --name-only --diff-filter=dr ${LAST_TAGGED_VERSION}..HEAD | \
|
||||||
grep -v -E "^[0-9a-f]{7} " | sort -u | zip ${ARCHIVE_INCR} -@
|
zip ${ARCHIVE_INCR} -@
|
||||||
|
|
||||||
export ARCHIVE_INCR_ARG="-i ${ARCHIVE_INCR} ${DELETIONS_FILE}"
|
export ARCHIVE_INCR_ARG="-i ${ARCHIVE_INCR} ${CHANGES_FILE}"
|
||||||
elif [[ -n $ARCHIVE_INCR && -z $LAST_TAGGED_VERSION ]]; then
|
elif [[ -n $ARCHIVE_INCR && -z $LAST_TAGGED_VERSION ]]; then
|
||||||
echo "Incremental archive was requested, but there is no previous version"
|
echo "Incremental archive was requested, but there is no previous version"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user