coder / coder/registry

rfc(git-clone) update repo and post pull script

Open
#47 5 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.