Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Creates a commit for turning items in. Does not automatically push.
- set -eu; # Exit script upon failure (bash's "strict" mode), unset variables are dangerous
- submission_directory='./submission'; # Config submission directory here
- # Switch to master branch
- current_branch=$(git branch);
- on_master='* master';
- if [[ "$current_branch" != *"$on_master"* ]];
- then
- printf "Not on master branch. Switching to master branch..."
- git checkout -f master
- fi
- # Remove submission directory if it exists.
- if [[ -d "$submission_directory" ]];
- then
- printf "Found existing submission directory located at: %s...\n" $submission_directory
- rm -r "$submission_directory";
- printf "Submission directory deleted.\n"
- fi
- # Create submission "build" directory
- printf "\nMaking submission directory...\n";
- mkdir "$submission_directory";
- printf "Directory made at %s\n" $submission_directory;
- # Copy relevant files to submission directory / TODO: change these to fit your directory structure
- printf "\nCopying relevant files...\n"
- cp -v src/*.js "$submission_directory"; # client-side React code
- cp -v src/*.css "$submission_directory"; # client-side stylesheets
- cp -v backend/*.js "$submission_directory"; # server-side backend auxiliary classes
- cp -v server.js "$submission_directory"; # server-side Express code
- # Remove individual blacklisted files / TODO: change these to fit your directory structure
- printf "\nRemoving extraneous files..."
- rm -v "$submission_directory"/index.*; # do not submit index-related files
- rm -v "$submission_directory"/setupTests.js; # do not submit test config
- rm -v "$submission_directory"/serviceWorker.js; # do not submit service worker
- rm -v "$submission_directory"/*.test.js; # do not submit tests
- printf "\nSubmission directory created. Located at: %s\n" $submission_directory;
- printf "\nRemoving everything else from the root directory from GIT...\n";
- git rm -r --cached . --ignore-unmatch;
- printf "\nAdding everything from submission directory to Git";
- git add -fv $submission_directory;
- printf "\nMoving added files to root level"
- git mv -fv $submission_directory/* ./;
- git add server.js;
- print "\nCommitting changes...";
- commits_ahead=$(git rev-list --left-right --count origin/master...master | awk '{print $2}');
- if [[ commits_ahead -lt 1 ]]; then
- printf "\nCommit not detected. Making commit...\n";
- git commit -m "Turning in files for submission to HW8";
- else
- printf "\nCommit detected. Overwriting commit...\n";
- git commit --amend --no-edit;
- fi
- # you will need to push on your own.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement