aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoroldmud0 <oldmud0@users.noreply.github.com>2019-04-03 22:58:05 -0500
committeroldmud0 <oldmud0@users.noreply.github.com>2019-04-03 22:58:05 -0500
commit9b4c18e8dc151ca0387e8d4514b8d9886d03caa7 (patch)
tree6c9f58c2511d7c625b530a45076aa60dea26044b
parentf4b31356df011decba4e157a6d8d2c24f17ade2e (diff)
Cover rename and deleted directory cases
-rwxr-xr-xscripts/update_manifest.js59
-rwxr-xr-xscripts/wasabi.sh13
2 files changed, 55 insertions, 17 deletions
diff --git a/scripts/update_manifest.js b/scripts/update_manifest.js
index 220439c5..19e1b152 100755
--- a/scripts/update_manifest.js
+++ b/scripts/update_manifest.js
@@ -30,7 +30,7 @@ argParser.addArgument([ "-f", "--full" ], {
});
argParser.addArgument([ "-i", "--incremental" ], {
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" ], {
metavar: "[executable file]", nargs: 1,
@@ -45,7 +45,7 @@ const {
executableArgs
} = argParser.parseArgs();
-const [incrementalZipFile, deletionsFile] = incrementalArgs || [];
+const [incrementalZipFile, changesFile] = incrementalArgs || [];
const [fullZipFile] = fullZipFileArgs || [];
const [executable] = executableArgs || [];
@@ -55,17 +55,56 @@ if (!incrementalZipFile && !fullZipFile) {
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 deleteActions = deletionsFile ? fs.readFileSync(deletionsFile)
+const dirsDeleted = new Set();
+const specialActions = changesFile ?
+ fs.readFileSync(changesFile)
.toString()
.trim()
- .split("\n").map(file => {
- // XXX: This does not delete empty directories. Finding them would
- // actually be a substantial amount of work because Git does not
- // give us a good way of finding directories that were deleted.
- return { action: "delete", target: file };
- }) : [];
+ .split("\n")
+ .map(line => line.split("\t"))
+ .map(([mode, target, source]) => {
+ switch (mode[0]) {
+ 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/";
@@ -83,7 +122,7 @@ const versionEntry = {
}
] : undefined,
update: incrementalArgs ? [
- ...deleteActions,
+ ...specialActions,
{
action: "dl",
url: urlBase + encodeURIComponent(path.basename(incrementalZipFile)),
diff --git a/scripts/wasabi.sh b/scripts/wasabi.sh
index 2067e5ed..a20c0e06 100755
--- a/scripts/wasabi.sh
+++ b/scripts/wasabi.sh
@@ -36,16 +36,15 @@ echo "Current tagged version: ${VERSION}"
if [[ -n $ARCHIVE_INCR && -n $LAST_TAGGED_VERSION ]]; then
echo "Incremental archive: ${ARCHIVE_INCR}"
- # Get deleted files
- export DELETIONS_FILE="deletions.txt"
- git log --diff-filter=D --summary ${LAST_TAGGED_VERSION}..HEAD | \
- grep "delete mode" | cut -d' ' -f 5- > ${DELETIONS_FILE}
+ # Get all files
+ export CHANGES_FILE="changes.txt"
+ git diff --summary ${LAST_TAGGED_VERSION}..HEAD > ${CHANGES_FILE}
# Get added/modified files
- git log --name-only --oneline --diff-filter=d ${LAST_TAGGED_VERSION}..HEAD | \
- grep -v -E "^[0-9a-f]{7} " | sort -u | zip ${ARCHIVE_INCR} -@
+ git diff --name-only --diff-filter=dr ${LAST_TAGGED_VERSION}..HEAD | \
+ 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
echo "Incremental archive was requested, but there is no previous version"
fi