Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Example 6] 1052997 #377

Open
wants to merge 1 commit into
base: ex6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
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