Skip to content

Commit 90e6fcd

Browse files
committed
Overhaul git scripts
1 parent bdb7a4f commit 90e6fcd

File tree

7 files changed

+35
-156
lines changed

7 files changed

+35
-156
lines changed

git_update_scripts/checkout-pr.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.

git_update_scripts/generic-updater.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
#!/usr/bin/env bash
2+
#parameters: $1=folder $2=username $3=branch $4=map $5=debug
23
set -e
34
repo_name="RedMew"
45

6+
folder=$1
7+
username=$2
8+
branch=$3
9+
map=$4
10+
511
if [ -z "$folder" ]; then
612
echo "Missing argument: folder."
713
exit 1
814
fi
9-
if [ -z "$repository" ]; then
10-
echo "Missing argument: repository."
15+
if [ -z "$username" ]; then
16+
echo "Missing argument: github username."
1117
exit 1
1218
fi
1319
if [ -z "$branch" ]; then
@@ -19,9 +25,17 @@ if [ -z "$map" ]; then
1925
exit 1
2026
fi
2127

22-
repository="https://github.com/$repository/$repo_name.git"
28+
if [ "$5" == 'true' ]; then
29+
debug=true
30+
else
31+
debug=$5
32+
fi
33+
34+
echo "Updating folder: \"$folder\"..."
35+
36+
url="https://github.com/$username/$repo_name.git"
2337

24-
git --git-dir=/factorio/scenarios/"$folder"/.git/ --work-tree=/factorio/scenarios/"$folder"/ fetch "$repository" "$branch" > /dev/null
38+
git --git-dir=/factorio/scenarios/"$folder"/.git/ --work-tree=/factorio/scenarios/"$folder"/ fetch "$url" "$branch" > /dev/null
2539
git --git-dir=/factorio/scenarios/"$folder"/.git/ --work-tree=/factorio/scenarios/"$folder"/ reset --hard "FETCH_HEAD" > /dev/null
2640
git --git-dir=/factorio/scenarios/"$folder"/.git/ --work-tree=/factorio/scenarios/"$folder"/ rev-parse --short HEAD
2741
git --git-dir=/factorio/scenarios/"$folder"/.git/ --work-tree=/factorio/scenarios/"$folder"/ log -1 --pretty=%B
@@ -31,7 +45,7 @@ rm /factorio/scenarios/"$folder"/redmew_git_banner.png -f
3145

3246
file=/factorio/scenarios/"$folder"/map_gen/maps/"$map".lua
3347

34-
if grep -q "data.presets" "$file"; then
48+
if ! grep -q "data.presets" "$file"; then
3549
echo "Deleting preset map data."
3650
rm /factorio/scenarios/"$folder"/map_gen/data/ -rf
3751
fi
@@ -47,3 +61,5 @@ else
4761
fi
4862

4963
touch /factorio/scenarios/"$folder"
64+
65+
echo "$folder updated from $username $branch successfully with map: $map"

git_update_scripts/github-webhook.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
#!/bin/bash
2+
#parameters: $1=branch
23
set -e #this forces an exit on any error
34
if [ "$1" != "develop" ]; then
45
exit 0
56
fi
67

7-
#arguments to script: folder=$1 repository=$2 branch=$3 map=$4 debug=$5
8-
script_path='/home/factorio/backend_scripts/git_update_scripts/update-from-args.sh'
8+
#arguments to script: $1=folder $2=username $3=branch $4=map $5=debug
9+
script_path='/home/factorio/backend_scripts/git_update_scripts/generic-updater.sh'
910
log_path='/home/factorio/backend_scripts/logs/github_webhook_output.txt'
1011

1112
{
1213
echo '------------------------------------------'
1314
date
1415
echo '-'
15-
"$script_path" develop origin develop default false
16+
"$script_path" develop Refactorio develop default false
1617
echo '-'
17-
"$script_path" dev-debug origin develop default true
18+
"$script_path" dev-debug Refactorio develop default true
1819
echo '-'
19-
"$script_path" crashsite origin develop crash_site false
20+
"$script_path" crashsite Refactorio develop crash_site false
2021
echo '-'
21-
"$script_path" diggy origin develop diggy false
22+
"$script_path" diggy Refactorio develop diggy false
2223
} >>"$log_path"

git_update_scripts/update-from-args.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

git_update_scripts/update-grilled.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

git_update_scripts/update-plague.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

plaguesplayground.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
#!/bin/bash
2+
#parameters: $1=folder $2=username $3=branch $4=map $5=debug
3+
##parameters: $1=username $2=branch $3=map $4=debug
24
set -e #this forces an exit on any error
35

4-
# arguments to script: repository=$1 branch=$2 map=$3 debug=$4
5-
6-
if [ -z "$1" ]; then
7-
echo "Missing argument: need to specify the repository."
8-
exit 1
9-
fi
10-
repository=$1
11-
126
if [ -z "$2" ]; then
137
branch="develop"
148
echo "No branch provided, using 'develop'."
@@ -18,8 +12,8 @@ fi
1812

1913
# If branch is develop or a PR, force them to take the Refactorio username.
2014
if [ "$branch" == "develop" ] || [[ $branch == pr/* ]]; then
21-
echo "Develop or PR branch selected, changing repository to Refactorio"
22-
repository="Refactorio"
15+
echo "Develop or PR branch selected, changing username to Refactorio"
16+
username="Refactorio"
2317
fi
2418

2519
if [ -z "$3" ]; then
@@ -38,10 +32,9 @@ fi
3832

3933
# Custom section for discord names =/= github usernames
4034

41-
#arguments to script: folder=$1 repository=$2 branch=$3 map=$4 debug=$5
42-
script_path='/home/factorio/backend_scripts/git_update_scripts/update-from-args.sh'
43-
log_path='/home/factorio/backend_scripts/logs/plaguesplayground_output.txt'
35+
#arguments to script: folder=$1 username=$2 branch=$3 map=$4 debug=$5
36+
script_path='/home/factorio/backend_scripts/git_update_scripts/generic-updater.sh'
4437

4538
echo '------------------------------------------'
4639
date
47-
"$script_path" RedMew $repository "$branch" "$map" "$debug"
40+
$script_path RedMew $username "$branch" "$map" "$debug"

0 commit comments

Comments
 (0)