Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Example 6] 1052988
Browse files Browse the repository at this point in the history
Signed-off-by: 1052988 <s1052988@mail.ncyu.edu.tw>
Jun-Ru Chang authored and 1052988 committed May 11, 2019
1 parent 54badda commit fba35ca
Showing 7 changed files with 95 additions and 5 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Example 5:
Example 6:

$ curl -s https://raw.githubusercontent.com/jrjang/ncyu-2019/ex5/scripts/ex5-pre.sh | bash -s -- https://github.com/YOUR_GITHUB_ACCOUNT/ncyu-2019

$ curl -s https://raw.githubusercontent.com/jrjang/ncyu-2019/ex5/scripts/ex5-test.sh | bash -s -- https://github.com/YOUR_GITHUB_ACCOUNT/ncyu-2019
$ curl -s https://raw.githubusercontent.com/jrjang/ncyu-2019/ex6/scripts/ex6-test.sh | bash -s -- https://github.com/YOUR_GITHUB_ACCOUNT/ncyu-2019
24 changes: 24 additions & 0 deletions data/ex6-branch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
official/ex0
official/ex1
official/ex2
official/ex3
official/ex3-2
official/ex4
official/ex4-2
official/ex4-3
official/ex5
official/ex5-2
official/ex6
origin/HEAD -> origin/ex0
origin/ex0
origin/ex1
origin/ex2
origin/ex3
origin/ex3-2
origin/ex4
origin/ex4-2
origin/ex4-3
origin/ex5
origin/ex5-2
origin/ex6
origin/ex6-2
24 changes: 24 additions & 0 deletions ex6-branch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
offical/ex0
offical/ex1
offical/ex2
offical/ex3
offical/ex3-2
offical/ex4
offical/ex4-2
offical/ex4-3
offical/ex5
offical/ex5-2
offical/ex6
origin/HEAD -> origin/ex0
origin/ex0
origin/ex1
origin/ex2
origin/ex3
origin/ex3-2
origin/ex4
origin/ex4-2
origin/ex4-3
origin/ex5
origin/ex5-2
origin/ex6
origin/ex6-2
Empty file added ex6.txt
Empty file.
30 changes: 30 additions & 0 deletions scripts/ex6-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash
set -e

if ! [[ "$1" =~ "https://github.com/" ]]; then
echo "Please provide your Github ncyu-2019 project url"
exit 1
fi

GITHUB_URL=$1
GITHUB_REPO=`echo ${GITHUB_URL#https://github.com/}`
GITHUB_PROJECT=`echo $GITHUB_REPO | cut -d '/' -f 2`
PROJECT_BRANCH=ex6
DIR_LOCAL=$GITHUB_PROJECT

GIT_NAME=`git config -l | grep user.name | cut -d '=' -f 2`

COMMIT_MSG="[Example 6] $GIT_NAME"

git checkout -t origin/$PROJECT_BRANCH -b $PROJECT_BRANCH
git diff origin/ex0 origin/$PROJECT_BRANCH-2 --name-only > ex6.txt
git add ex6.txt
git branch -r > ex6-branch.txt
git add ex6-branch.txt
git commit -s -q --amend -m "$COMMIT_MSG"
git push -f -q origin HEAD:refs/heads/$PROJECT_BRANCH

hub pull-request -b jrjang/$GITHUB_PROJECT:$PROJECT_BRANCH -h $GITHUB_REPO:$PROJECT_BRANCH -m "$COMMIT_MSG"
echo "[STATUS] Example 6: Github PR done"

echo "[STATUS] Example 6: done"
14 changes: 14 additions & 0 deletions scripts/ex6-verify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e

if [ `cat ex6.txt | wc -l` -ne 0 ]; then
echo "Your push operation is incorrect!"
exit 1
fi

if [ `diff ex6-branch.txt data/ex6-branch.txt | wc -l` -ne 0 ]; then
echo "Your adding remote operation is incorrect!"
exit 1
fi

exit 0
2 changes: 1 addition & 1 deletion scripts/verify.sh

0 comments on commit fba35ca

Please sign in to comment.