-
Notifications
You must be signed in to change notification settings - Fork 73
Preventing Corrupted Workspace #14
Comments
Here's a bit of code we're using to workaround the // Make sure the working tree is clean before fetching/merging
var workspace = grunt.shipit.config.options.workspace;
if (typeof workspace !== 'undefined') {
if (grunt.file.exists(workspace)) {
grunt.log.writeln('resetting preexisting workspace ');
grunt.shipit.local('git reset --hard HEAD', {cwd: workspace});
}
} We put this in a grunt task called $ grunt setup:qa shipit:qa deploy This is a quick hack, but it seems to work for our case (haven't tried the shallowClone option). To verify this:
|
@brycefisher I know some issues when the repository stay dirty, implementing a hard reset will fix that for sure. I just want to be sure that it will not have side effects. I am pretty sure that |
That's a great question! Yeah, we need to be sure before making any changes. So, I just did an experiment on my machine: #!/bin/bash
echo Create a dummy project to experiment on
mkdir -p /tmp/git-reset-test/ && cd /tmp/git-reset-test/
npm install --save lodash
echo "The README" > README.md
echo Setup git
git init
echo "node_modules" > .gitignore
git add . && git commit -m "initial commit"
echo Dirty the working tree
touch extra_file.txt
rm README.md
git status
echo Reset hard
git reset --hard HEAD
echo Verify Project State
ls -lah
cat README.md At the end of this:
I imagine that's what you want to have happen before deployment most of the time. |
@brycefisher OK good, we need to add this step to the deployment process, do you want to make a PR? |
Yeah! I'd love to. It might take me a take or two put one together, but I'm happy to contribute this enhancement. |
@brycefisher good! |
Any traction here? It seems like it would be a good idea to also include something like a It seems like inevitably, something gets messed up in your workspace and it would be nice to delete it with a task rather than |
Hah, "a week or two" has become 2 months. My apologies @timkelty. I've just put together a PR. We'll see if the tests pass :-) |
@brycefisher good thank you |
Thanks @brycefisher ! |
@neoziro Can we get a release with this? |
We use shipit and really like it. Today, we ran into a bit of an edge case, and I'd like to suggest a change OR get advice on how to override the default deploy:fetch task.
What happened was this -- somehow my workspace was altered. Grunt-shipit executed during deploy:fetch a git checkout , but this kept my working directory dirty.
I'd like to insert an extra local command
git reset --hard HEAD
after the checkout but before the rsync. Would you be interested in having that in this project generally or is more of an edge case for my particular project?The text was updated successfully, but these errors were encountered: