Skip to content

Instantly share code, notes, and snippets.

@oberrich
Last active October 5, 2021 00:52
Show Gist options
  • Save oberrich/d0db45cb71fdbf185ec7c922b6b2b6d6 to your computer and use it in GitHub Desktop.
Save oberrich/d0db45cb71fdbf185ec7c922b6b2b6d6 to your computer and use it in GitHub Desktop.
#!/bin/bash
source $HOME/.keychain/${HOSTNAME}-sh
cd ~/
if [ ! -d "phnt_maintain" ]; then
mkdir phnt_maintain
fi
PHNT_CHANGED=0
cd phnt_maintain
# setup local processhacker repo
if [ ! -d "ph-main" ]; then
git clone git@github.com:processhacker/processhacker.git ph-main
PHNT_CHANGED=1
fi
cd ph-main
# fetch changes
git fetch
# check for changes in phnt dir
if [ "$PHNT_CHANGED" -eq "0" ]; then
git diff --quiet origin/master..master -- phnt || PHNT_CHANGED=1
fi
if [ "$PHNT_CHANGED" -eq "1" ]; then
# pull changes if any
git pull origin master
cd ..
# remove old phnt_nightly repo
rm -rf phnt_nightly
# init new local phnt_nightly repo
git init phnt_nightly
cd phnt_nightly
# pull in local processhacker repo
git remote add origin ../ph-main
git pull origin master
# filter out everything outside of phnt/include
export FILTER_BRANCH_SQUELCH_WARNING=1
git filter-branch --prune-empty --subdirectory-filter phnt/include master
cat > LICENSE <<'EOF'
license stuff
EOF
cat > README.md <<'EOF'
readme stuff
EOF
git add README.md
git add LICENSE
timestamp=$(date +%c)
git commit -m "Updated repo at $timestamp"
# force push to oberrich/phnt_nightly
git push git@github.com:oberrich/phnt_nightly.git -f
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment