rfc(git-clone) update repo and post pull script
- Dominant language
- HCL
- Stars
- 79
- Forks
- 161
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 38
Description
Looking for thoughts on these two items, I'm willing to submit a PR if we like it.
1. If the repo already exists, we should fetch updates and perform a ff merge on an opt-in basis.
Something like below, I just added this to my dotfiles.
Might need to rework the merge logic to select the correct branch.
```bash
if [ -v PROJECT_DIRECTORY ]; then
echo "Checking for project updates"
current_branch=$(git rev-parse --abbrev-ref HEAD)
# Sync remote changes
git -C "${PROJECT_DIRECTORY}" fetch origin
# Apply updates if no conflicts
git -C "${PROJECT_DIRECTORY}" merge "origin/${current_branch}" --ff-only
fi
```
2. After successfully cloning, or performing a ff merge, we should run a "setup script" if found to perform repo specific setup.
This is currently what I have in my dotfiles, doesn't matter if the script is executable or not.
```bash
# Prep cloned workspace via any found `coder.bootstrap` executable files in the project directory.
if [ -v PROJECT_DIRECTORY ]; then
echo "Prepping Project Workspace..."
find "${PROJECT_DIRECTORY}" -name coder.bootstrap -type f -print -exec bash {} \;
fi
```
Contributor guide
Assessment
This issue has not been assessed yet.