setup dev environment

This commit is contained in:
2021-07-29 11:58:27 -04:00
parent a390167598
commit a77495e15e
17 changed files with 549 additions and 0 deletions

59
upstreamUtils/step1.js Normal file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/env node
const child_process = require('child_process');
const util = require('util');
const fs = require('fs');
function execAsync(cmd, callback) {
const c = child_process.exec(cmd, callback);
c.stdout.pipe(process.stdout);
c.stderr.pipe(process.stderr);
return c;
}
const exec = util.promisify(execAsync);
const readFile = util.promisify(fs.readFile);
function realname(type, short) {
for (var i=0; i<=9999; i++) {
for (const prefix of ['', '0', '00', '000']) {
const full = 'patches/'+type+'/'+prefix+i+"-"+short;
if (fs.existsSync(full)) {
return full;
}
}
}
throw new Error(`patch not found type=${type} short=${short}`)
}
function parse(prop) {
return new Map(prop.replace(/\r/g,"").split("\n").filter(line => line !== "").map(line => {
const [key, value] = line.split("=");
return [key, value];
}));
}
(async () => {
await exec('rm -fr patches *-Server *-API');
await exec('git checkout HEAD patches');
await exec('./gradlew applyPatches');
const config = parse(await readFile(process.argv.slice().pop(), {encoding: 'utf8'}));
const patches = config.get('list').split(',').map(element => {
const [type, short] = element.split('/');
return realname(type, short);
});
const patchesCmd = patches.join(' ');
const configBlack = config.get('useBlackList');
const useBlackList = configBlack === 'True' ? true : (configBlack === 'False' ? false : void 0);
if (useBlackList === void 0) {
throw new Error('Illegal value');
}
if (useBlackList) {
await exec('rm '+patchesCmd);
} else {
await exec('rm -fr patches');
await exec('git checkout HEAD '+patchesCmd);
}
await exec('./gradlew applyPatches');
})();

View File

@@ -0,0 +1,26 @@
#!/bin/bash
set -e
upstream=`cd "$1" && pwd`
upstream_commmit=`cd "$upstream" && git rev-parse HEAD`
upstream_name="$(eval echo `cd "$upstream" && grep '^rootProject.name =' settings.gradle.kts | awk '{print $3;}'`)"
cd Luna-API
if cat "$upstream/patches/api"/*.patch | patch -p1 --merge --no-backup-if-mismatch; then
:
else
:
fi
git add .
git commit -m"$upstream_name API Changes
commit $upstream_commmit"
cd ../Luna-Server
if cat "$upstream/patches/server"/*.patch | patch -p1 --merge --no-backup-if-mismatch; then
:
else
:
fi
git add .
git commit -m"$upstream_name Server Changes
commit $upstream_commmit"

25
upstreamUtils/step2.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
set -e
rm -fr *.patch
ver="$(git rev-parse HEAD)"
rootProject.name(){
name="$2"
}
eval "$(grep '^rootProject.name =' settings.gradle.kts)"
cd "$name-Server"
onecommit() {
git reset --soft base
git commit -m"$name $1 Changes
commit $ver
$(git log --format=%B --reverse HEAD..HEAD@{1})"
}
onecommit Server
git format-patch --no-signature --zero-commit --full-index --no-stat -N -o .. HEAD^
cd "../$name-API"
onecommit API
git format-patch --no-signature --zero-commit --full-index --no-stat -N -o .. HEAD^
cd ..