From 36d0a9d281e7e124fe908bdad724e0b336a8024c Mon Sep 17 00:00:00 2001 From: Blank_Alt <12406-Blank_Alt@users.noreply.gitgud.io> Date: Wed, 24 May 2023 23:13:00 +0000 Subject: [PATCH] Tweak compile.sh, devTools/switchBranch.sh and devTools/PreCompile.sh --- compile.sh | 10 +++- devTools/PreCompile.sh | 58 +++++++++++++++----- devTools/switchBranch.sh | 114 ++++++++++++++++++++++++++++++++++----- 3 files changed, 156 insertions(+), 26 deletions(-) diff --git a/compile.sh b/compile.sh index bede064779d..3b128c65c60 100755 --- a/compile.sh +++ b/compile.sh @@ -1,6 +1,7 @@ #!/bin/bash output=/dev/stdout +name=FC_pregmod # displays help text function displayHelp() { @@ -16,6 +17,7 @@ Options: -t, --themes Generate theme files -m, --minify Minify output files --ci CI mode + -f, --f Final file name HelpText } @@ -77,7 +79,7 @@ function compile() { fi fi - file="bin/FC_pregmod.html" + file="bin/${name}.html" # Find and insert current commit if [[ "$ci" ]]; then @@ -85,7 +87,7 @@ function compile() { elif [[ -d .git ]]; then COMMIT=$(git rev-parse --short HEAD) if [[ "$usehash" ]]; then - file="bin/FC_pregmod_${COMMIT}.html" + file="bin/${name}${COMMIT}.html" fi fi if [[ "$minify" ]]; then @@ -158,6 +160,10 @@ else --ci) ci="true" ;; + -f | --file) + name=$2 + shift + ;; *) echoError "Unknown argument $1." displayHelp diff --git a/devTools/PreCompile.sh b/devTools/PreCompile.sh index 248695a23d8..f513833b41e 100755 --- a/devTools/PreCompile.sh +++ b/devTools/PreCompile.sh @@ -1,12 +1,46 @@ -#!/bin/ksh -mega-login $1 $2 #U=$1 P=$2 rDir=$3 lDir=$4 Reqs:MEGAcmd,git -while true;do gen=0;cd $4; - if [[ `echo $?` -gt 0 ]];then mkdir -p $4&&git clone -q --depth 1 https://gitgud.io/pregmodfan/fc-pregmod.git $4&&cd $4 - if [[ ! `mega-ls $3|cut -c21-24|paste -sd,` =~ `git log|head -1|cut -c8-11` ]];then gen=1;fi #stackoverflow.com/a/15394738 - fi - git fetch -q && if [ `git rev-list ...origin|wc -l` -gt 0 ];then git pull -q&&gen=1;fi #stackoverflow.com/a/17192101 - if [[ $gen > 0 ]];then rm bin/*;./compile.sh -q&&cd bin/ - mv *.h* FC-`git log -1 --format=%cd --date=format:%m-%d-%Y-%H-%M`-`git log|head -1|cut -c8-11`.html - mega-put -c *.h* $3&&mega-rm $3`mega-ls $3|head -n 1` - fi -clear;sleep 15m;done \ No newline at end of file +#!/bin/bash +email=xyz1256@corp.com +password=12345678 +mega-login $email $password +remote=FC/ +local=fc/ +gen=0; +runstep=${1:-0} +hash=$(git log --oneline|head -n 1|cut -c1-7) + +find $local > /dev/null +if [[ `echo $?` > 0 ]]; then + git clone -q https://gitgud.io/pregmodfan/fc-pregmod.git --depth 1 $local + if [[ ! `mega-ls $remote|grep .html|cut -c21-29|paste -sd,` =~ $hash ]];then + gen=1; + fi # stackoverflow.com/a/15394738 +fi +cd $local + +find js/000-browserSupport.js > /dev/null +if [[ `echo $?` > 0 ]]; then + echo "creating file to work with browsers that do not support globalThis." + echo "const globalThis = eval.call(undefined, 'this');" > js/000-browserSupport.js +fi + +git fetch -q && if [[ $runstep == 0 && `git rev-list ...origin/pregmod-master|wc -l` > 0 ]]; then + git reset --hard HEAD -q && git pull -q && gen=1; +fi # stackoverflow.com/a/17192101 + +if [[ $gen > 0 || $runstep == 1 ]]; then + echo "Applying WebGL decensor patch." + sed -i '1,/p.applyPanty = true/ s/p.applyPanty = true/p.applyPanty = false/' src/art/webgl/art.js + sed -i 's/p.underage = slave.age < 18 || slave.visualAge < 18/p.underage = false/' src/art/webgl/art.js + sed -i 's#p.height = Math.max(slave.height, 140); // clamp underage#p.height = slave.height;#' src/art/webgl/art.js + sed -i 's#morphs.push(["physicalAgeYoung", -(Math.max(slave.visualAge, 18)-20)/10]) // clamp underage#morphs.push(["physicalAgeYoung", -(slave.visualAge-20)/10])#' src/art/webgl/art.js +fi + +if [[ $gen > 0 || $runstep == 2 ]]; then + rm bin/*.html && ./compile.sh -q -m -f FC-`git log -1 --format=%cd --date=format:%Y-%m-%d-%H-%M`-$hash +fi +if [[ $gen > 0 || $runstep == 3 ]]; then mega-put -c bin/*.html $remote; fi +if [[ $gen > 0 || $runstep == 4 ]]; then + if [[ `mega-ls $remote|grep .html|grep -v revert-RA|wc -l` > 2 ]]; then + mega-rm $remote`mega-ls $remote|grep .html|grep -v revert-RA|head -n 1` + fi +fi diff --git a/devTools/switchBranch.sh b/devTools/switchBranch.sh index bca3f4fb8e9..bb197fe6705 100644 --- a/devTools/switchBranch.sh +++ b/devTools/switchBranch.sh @@ -1,21 +1,111 @@ # git push --set-upstream origin origin/pregmod-master / git checkout -b pregmod-master --track origin/pregmod-master +mainBranch="pregmod-master" previousBranch="Not found" + +function displayHelp() { +cat <<HelpText +Usage: $0 [OPTION]... +Always pushes commit(s) / the current branch +Order of operation: new (if enabled) -> push (if not closed after creating a new branch) -> sync (if enabled) -> change branch (if enabled) + -> delete previous branch (if enabled) + +Options: + -s, --sync : Sync upstream/$mainBranch + -d, --delete : Delete previous branch + -m, --move : Change current branch to either; + supplied / previous, the choice currently + follows the flow as written i.e supplied -> previous + -b, --branch X : Set supplied branch to X + -c, --create Y : Create the new branch Y + -h, --help : Show this help text + + e.g. + Before: + git status + On branch XYZ + Your branch is ahead of 'origin/XYZ' by 5 commits. + + git branch --list + * XYZ + $mainBranch + ..... + + During: + $0 -b $mainBranch -c -d + Branches: Supplied ($mainBranch) / previous (XYZ) + Sync Master? Y/N: N + + After: + git branch --list + * $mainBranch + ..... + + All five new commits for branch XYZ were pushed prior to the switch over and + then afterwards the local copy of branch XYZ was deleted. +HelpText +} + if [[ $(git rev-parse --quiet --abbrev-ref @{-1} 2>/dev/null) && $? -eq 0 ]]; then previousBranch=$(git rev-parse --abbrev-ref @{-1}) fi -read -p "Push commits/branch? Y/N: " commit -read -p "Sync Master? Y/N: " sync -read -p "Switch to supplied branch ($1) / previous ($previousBranch)? Y/N: " switch +if [[ "$#" -eq 0 ]]; then + echo -e "For more options see $0 -h.\n" +fi + +while [[ "$1" ]]; do + case $1 in + -s | --sync) + sync="true" + ;; + -d | --delete) + delete="true" + ;; + -m | --move) + change="true" + ;; + -b | --branch) + tgtBranch=$2 + shift + ;; + -c | --create) + newBranch=$2 + shift + ;; + -h | --help) + displayHelp + exit 0 + ;; + *) + echo "Unknown argument $1." + displayHelp + exit 1 + ;; + esac + shift +done + +if [[ "$newBranch" ]]; then + if [[ $(git stash show 2>/dev/null | echo $?) -gt 0 ]]; then git stash save *; fi + git checkout -qb $newBranch + if [[ $(git stash show 2>/dev/null | echo $?) -gt 0 ]];then + git stash show + read -p "Pop the latest stash? (y/n): " stash + [ "$stash" == "y" ] && git stash pop; + fi + read -p "Exit? (y/n): " exit + [ "$exit" == "y" ] && exit; +fi + +git push -q 2>/dev/null || git push -qu "origin" HEAD 1>/dev/null +echo "Branches: Supplied ($tgtBranch) / previous ($previousBranch)" -if [[ $commit == "Y" ]]; then - git push -q 2>/dev/null || git push -qu origin $(git rev-parse --abbrev-ref HEAD) 1>/dev/null +if [[ "$sync" ]]; then + if [[ $(git stash show 2>/dev/null | echo $?) -gt 0 ]]; then git stash save *; fi + git checkout -q origin/$mainBranch && git reset --hard upstream/$mainBranch -q && git push -q && git checkout -q @{-1} + if [[ $(git stash show 2>/dev/null | echo $?) -gt 0 ]]; then git stash pop; fi fi -if [[ $sync == "Y" ]]; then - git stash save * && git checkout -q pregmod-master && git reset --hard upstream/pregmod-master -q && git push -q && git checkout -q @{-1} && git stash pop +if [[ "$change" ]]; then + if [[ "$tgtBranch" ]]; then git checkout -q origin/$tgtBranch; else git checkout -q @{-1}; fi fi -if [[ $switch == "Y" ]]; then - if [[ -n $1 ]];then git checkout -q $1; else git checkout -q @{-1}; fi -fi -read -p "Delete previous branch ($(git rev-parse --abbrev-ref @{-1}))? Y/N: " del -if [[ $del == "Y" ]]; then git branch -qD @{-1}; fi +if [[ "$delete" ]]; then git branch -qD @{-1}; fi -- GitLab