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

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

Open
djarbz opened this issue Oct 24, 2024 · 5 comments
Open

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

djarbz opened this issue Oct 24, 2024 · 5 comments
Labels
module-idea A new module idea or suggestion

Comments

@djarbz
Copy link
Contributor

djarbz commented Oct 24, 2024

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.
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
  1. 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.
# 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
@coder-labeler coder-labeler bot added the module-idea A new module idea or suggestion label Oct 24, 2024
@matifali
Copy link
Member

I agree with the proposal if we also add a switch to retain the previous behaviour of the git-clone module.
@johnstcn what do you think?

@johnstcn
Copy link
Member

Re: 1) I think this is fine on an opt-in basis

Re: 2) This could be done as a separate step; there may be cases where this requires specific dependencies that are not yet available inside the workspace?

@matifali
Copy link
Member

For me, 2) is out of scope for git-clone.

@gjrtimmer
Copy link

I like this, working on the same thing for myself; I would like to offer a suggestion: instead of all the different file locations that everybody is using, why not a standardized approach, I prefer myself the location of .coder/bootstrap or .coder/bootstrap.sh in my repositories, gives more flexibility for the future and allows for multiple files/scripts regarding coder workspaces to be organized in a .coder folder just like other platforms have either own folders, .gitlab .github etc. What do yo think?

@djarbz
Copy link
Contributor Author

djarbz commented Dec 4, 2024

Sorry I've been MIA for a month.

RE 2) I think it would still be in scope, at least until we can figure out module dependencies. If we added it as a separate module, then we wouldn't be able to tell if the clone completed or not.

I think having a .coder directory makes sense, then we could also match based on the other "init" style scripts that coder uses elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module-idea A new module idea or suggestion
Projects
None yet
Development

No branches or pull requests

4 participants