-
Notifications
You must be signed in to change notification settings - Fork 0
/
poolc_push.sh
executable file
·56 lines (46 loc) · 1.26 KB
/
poolc_push.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
PROBLEM_NAME=`echo "$1" | tr [:lower:] [:upper:]`
SAVE_PATH=./problems
GITHUB_PATH=./_poolc
SCRIPT_PATH=./_script
PROBLEM_PATH=${SAVE_PATH}/`echo "${PROBLEM_NAME}" | tr [:upper:] [:lower:]`
PROBLEM_SOLUTION_FILENAME=$PROBLEM_PATH/solution.py
SUBMIT_FILENAME=doodoori2.py
COMMIT_LOG=doodoori2.py
echo_usage () {
SCRIPT="$(basename "$0")"
echo "Usage: ${SCRIPT} PROBLEM_NAME"
exit
}
if [ -z "$PROBLEM_NAME" ]; then
echo_usage
fi
if [ ! -d "$GITHUB_PATH" ]; then
echo "ERROR: ${GITHUB_PATH} is not exists. Please checkout https://github.com/PoolC/algospot "
exit
fi
if [ ! -d "$GITHUB_PATH/.git" ]; then
echo "ERROR: ${GITHUB_PATH}/.git is not exists. Please checkout https://github.com/PoolC/algospot "
exit
fi
if [ ! -d "$PROBLEM_PATH" ]; then
echo "ERROR: ${PROBLEM_PATH} is not exists."
exit
fi
if [ ! -f "$PROBLEM_SOLUTION_FILENAME" ]; then
echo "ERROR: ${PROBLEM_SOLUTION_FILENAME} is not exists. "
exit
fi
#1 pull
pushd $GITHUB_PATH > /dev/null
git pull
popd > /dev/null
mkdir -p $GITHUB_PATH/$PROBLEM_NAME
cp ${PROBLEM_SOLUTION_FILENAME} $GITHUB_PATH/$PROBLEM_NAME/${SUBMIT_FILENAME}
pushd $GITHUB_PATH > /dev/null
git add ./$PROBLEM_NAME/${SUBMIT_FILENAME}
git status
git commit -m "${PROBLEM_NAME} ${COMMIT_LOG}"
git push
git status
popd > /dev/null