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

Add script to simplify developing process #678

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
52 changes: 52 additions & 0 deletions use-fork.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
# See doc/developers.adoc for purposes of this script

# Got to the root of project (where this script itself is located)
cd `dirname "$0"`

# Determine sub-type
RUNTIME=""
if [[ $1 == "runtime" ]]; then
RUNTIME="runtime_"
cd runtime
shift
fi

if [[ $# -lt 2 ]]; then
echo "Updates submodule in the project to you fork"
echo "See doc/developers.adoc or https://doc.kaitai.io/developers.html#_developing_new_feature"
echo "Usage:"
echo " $0 [runtime] <PROJECT> <GitHub user> [<branch in you GitHub repository>]"
exit 2
fi

PROJECT=$1
GH_USER=$2
BRANCH=$3
URL="https://github.com/${GH_USER}/kaitai_struct_${RUNTIME}${PROJECT}.git"

BRANCH_TITLE="${BRANCH}"
if [[ "${BRANCH}" -eq "" ]]; then
BRANCH_TITLE="<all>"
fi

echo "Project : ${PROJECT}"
echo "GitHub User: ${GH_USER}"
echo "Branch : ${BRANCH_TITLE}"
echo "Repository : ${URL}"
echo `pwd`

# Select subproject you want to modify
cd ${PROJECT}
# Add your repository as remote with name my-repo
git remote add ${GH_USER} ${URL}

if [[ "${BRANCH}" -eq "" ]]; then
# Get you work
git fetch ${GH_USER}
else
# Get you work
git fetch ${GH_USER} ${BRANCH}
# Switch to you feature branch
git checkout ${BRANCH}
fi