Comments (11)
Here's a bit of code we're using to workaround the deploy:fetch
using an old version of grunt shipit:
// 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 setup
then we run deployments like this:
$ 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:
- Run your deployment as normal and ensure that the workspace is in place
- Modify a file in your workspace
- Run only the
grunt setup
task git status
from inside your workspace should now show your workspace is clean
from shipit-deploy.
@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 git reset --hard
doesn't remove any files (node_modules, etc..) but I am not totally sure. Do you think it's completely safe to do a git reset --hard
?
from shipit-deploy.
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:
- node_modules directory is unchanged
- the README.md is "undeleted"
- extra_file.txt is unchanged since it wasn't in version control to begin with
I imagine that's what you want to have happen before deployment most of the time.
from shipit-deploy.
@brycefisher OK good, we need to add this step to the deployment process, do you want to make a PR?
from shipit-deploy.
Yeah! I'd love to. It might take me a take or two put one together, but I'm happy to contribute this enhancement.
from shipit-deploy.
@brycefisher good!
from shipit-deploy.
Any traction here?
It seems like it would be a good idea to also include something like a deploy:clean-workspace
.
It seems like inevitably, something gets messed up in your workspace and it would be nice to delete it with a task rather than rm -rf
ing stuff.
from shipit-deploy.
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 :-)
from shipit-deploy.
@brycefisher good thank you
from shipit-deploy.
Thanks @brycefisher !
from shipit-deploy.
@neoziro Can we get a release with this?
from shipit-deploy.
Related Issues (20)
- how to know if the process is a deploy or rollback inside a task ? HOT 2
- Password prompt during deploy on OSX HOT 4
- Cache workspace option HOT 3
- `ignores` being...ignored HOT 2
- Deployment does not delete files properly if Rsync is not available HOT 3
- "ignores" doesn't seem to do anything HOT 1
- What is the preferred way to install dependencies ? HOT 1
- TypeError: Cannot read property 'filter' of undefined HOT 9
- deploy:publish task fails with cannot read property filter of undefined HOT 3
- deploy:update Authentication Failed HOT 3
- remoteCopy invalid path due to posix HOT 3
- bashism in updateSymbolicLink HOT 3
- How do we abort releases when the remote npm install fails? HOT 2
- Without git section HOT 1
- Ignores SSH key config HOT 6
- May be add `verbosity` level like [ v | vv | vvv ] ? HOT 2
- May be add `default` environment|stage? HOT 6
- Deploy fails because `mv -T` is illegal option HOT 4
- Deploy:update fails to load lib/shipit HOT 2
- Symlink command fails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shipit-deploy.