Giter Club home page Giter Club logo

Comments (11)

brycefisher avatar brycefisher commented on June 19, 2024

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:

  1. Run your deployment as normal and ensure that the workspace is in place
  2. Modify a file in your workspace
  3. Run only the grunt setup task
  4. git status from inside your workspace should now show your workspace is clean

from shipit-deploy.

gregberge avatar gregberge commented on June 19, 2024

@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.

brycefisher avatar brycefisher commented on June 19, 2024

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.

gregberge avatar gregberge commented on June 19, 2024

@brycefisher OK good, we need to add this step to the deployment process, do you want to make a PR?

from shipit-deploy.

brycefisher avatar brycefisher commented on June 19, 2024

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.

gregberge avatar gregberge commented on June 19, 2024

@brycefisher good!

from shipit-deploy.

timkelty avatar timkelty commented on June 19, 2024

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 -rfing stuff.

from shipit-deploy.

brycefisher avatar brycefisher commented on June 19, 2024

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.

gregberge avatar gregberge commented on June 19, 2024

@brycefisher good thank you

from shipit-deploy.

timkelty avatar timkelty commented on June 19, 2024

Thanks @brycefisher !

from shipit-deploy.

timkelty avatar timkelty commented on June 19, 2024

@neoziro Can we get a release with this?

from shipit-deploy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.