Skip to content

Commit 3c577b4

Browse files
committed
refine the scripts
1 parent 2354860 commit 3c577b4

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

scripts/readme.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,3 @@ FILE=`echo ${FILE} | sed "s/.*\/algorithms/\.\/algorithms/"`
5050

5151
echo "|${QUESTION_FRONTEND_ID}|[${QUESTION_TITLE}](${URL}) | [C++](${FILE})|${QUESTION_DIFFICULTY}|"
5252

53-
echo "git commit -am \"New Problem Solution -\\\"${QUESTION_TITLE}\\\"\""

scripts/workflow.sh

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,56 @@ platform=`detect_os`
3636
leetcode_url=$1
3737

3838
get_question_slug ${leetcode_url}
39-
4039
dir_name=`echo ${QUESTION_TITLE_SLUG} | awk -F '-' '{for (i=1; i<=NF; i++) printf("%s", toupper(substr($i,1,1)) substr($i,2)) }'`
41-
4240
dir_name=`echo ${dir_name:0:1} | tr '[A-Z]' '[a-z]'`${dir_name:1}
4341

4442
mkdir -p ${dir_name}
4543
echo "Step 1 : Created \"${dir_name}\" directory!"
4644
cd ${dir_name}
45+
WORKING_DIR=`pwd`
4746

4847
file=`${SCRIPT_PATH}/comments.sh ${leetcode_url} | grep updated | awk '{print $1}'`
4948
echo "Step 2 : Created \"${dir_name}/${file}\" source file!"
50-
51-
git add ${file}
49+
5250
echo "Step 3 : Run \"git add ${dir_name}/${file}\"!"
51+
git add ${file}
5352

5453
vi "${file}"
5554
echo "Step 4 : Edited the \"${dir_name}${file}\"!"
56-
57-
output=`${SCRIPTPATH}/readme.sh ${file}`
58-
readme=`echo "${output}" | head -n 1`
59-
commit=`echo "${output}" | tail -n 1`
55+
readme=`${SCRIPT_PATH}/readme.sh ${file}`
56+
readme=`echo "${readme}" | head -n 1`
6057

6158
if [[ "$platform" == "macos" ]]; then
6259
echo $readme | pbcopy
6360
else
6461
echo $readme
6562
read -n 1 -s -r -p "Please copy the line above & press any key continue to edit README.md"
6663
fi
67-
6864
echo "Step 5 : Copied the readme text to Clipboard!"
69-
vi ${SCRIPTPATH}/../README.md
65+
vi ${SCRIPT_PATH}/../README.md
66+
7067
echo "Step 6 : Edited the \"README.md\"!"
68+
QUESTION_TITLE=`echo "${readme}" | awk -F '|' '{print $3}' | sed 's/\[/\]/' |awk -F ']' '{print $2}'`
69+
commit="git commit -m \"New Problem Solution -\\\"${QUESTION_TITLE}\\\"\""
7170

72-
echo "Step 7 : You can commit the changes by running the following command line..."
71+
echo "Step 7 : It's ready to commit to git repository ..."
7372
echo ""
74-
echo " ${commit}"
73+
echo " ${commit} \\"
74+
echo " ${WORKING_DIR}/${file} \\"
75+
echo " ${SCRIPT_PATH}/../README.md"
76+
echo ""
77+
78+
#git status
79+
80+
commit="${commit} \"${WORKING_DIR}/${file}\" \"${SCRIPT_PATH}/../README.md\""
81+
82+
while true; do
83+
read -p "Do you wish to commit them (y/n) ?" yn
84+
case $yn in
85+
[Yy]* ) echo "/bin/bash -c ${commit}"; break;;
86+
[Nn]* ) exit;;
87+
* ) echo "Please answer yes or no.";;
88+
esac
89+
done
90+
91+
echo "Done!"

0 commit comments

Comments
 (0)