Out of band syncing to a local git branch.
This started as an experiment to see how commits could be created without
modifying the working directory, the index, or the state of HEAD. The end
result is like a cross between rsync
and git stash
using a specified
branch.
This allows you to deploy your current working directory:
- without polluting your master branch with build artifacts
- without modifying your current checkout at all:
- no branch switching
- no index clobbering
- no complaining about clobbering unstaged changes
Here's how you would use it to push your current working directory to a git push based hosting provider (like Heroku):
$ git-snapshot production
Creating branch 'production' if it doesn't exist...
Creating index... (this can take a while)
Creating tree from index...
Created tree 1e035b51027ba785c74155025cd616bbd20d8d17
Creating commit...
Created commit f2527eb28622d7a17403f723d36584027e595723
$ git push hosting production:master
In order of appearance:
- http://git-scm.com/docs/git-branch
- http://git-scm.com/docs/git-rev-parse
- http://git-scm.com/docs/git-ls-files
- http://git-scm.com/docs/git-hash-object
- http://git-scm.com/docs/git-update-index
- http://git-scm.com/docs/git-write-tree
- http://git-scm.com/docs/git-commit-tree
- http://git-scm.com/docs/git-update-ref
- Option to create tag instead of branch
- Specify commit message
- Don't do empty commits, it means the branch is already up to date
- Find portable replacement for
stat
If I read this correctly, this combines commit-head-onto-deploy and commit-build-products-to-deploy, which I didn't want to do, I want two commits.
You're just showing me code that does something different, what I'm interested in is what your design goals are, why you think different is better. This might be better done in a hangout, I do want feedback, but I'm not sure what to do with this. I could have written onto and commit as a single atomic operation, I didn't do that on purpose.
It doesn't facilitate composability. The existing commands mostly (--install is an exception) do one thing, so you can choose to use the whole set of commands, or just pick a few you find useful, for example:
it doesn't facilitate running one by one, so you can see what it did, which I think is helpful to people who are having "wtf does this slc build command do, and why would I need it" moment, they can do each command in sequence, and see the result. This is also why I log every command done during build to the console, I want it to be very clear what the tool is doing, so people can look at the output and be "ah, ha, I get it" without reading the docs. (well, knowledgable people, the others will have to read the docs)
it melds development source and build products into a single giant commit, whereas how I did it always added two commits to the deploy branch: the first was a literal copy of the exact source tree, trivially verifiable to be correct, either via git diff, or examination of the tree object hash, and the second was a commit of build products, so you can see exactly what the build artificacts were. you can also do a
git status
between --install and --commit, you should observe no change in status.... that all build products are ignored, and the build process did not modify any of your source files.Note how a bunch of people who didn't know about git commit-tree suggested I do this is:
This sequence when done repeatedly over time to a deploy branch evolves a state that is a munge of all history, the commit-tree based approach throws away all previous src and build product state.
Note the above also leaves you on the deploy branch, which is why I think its reasonable that
slc --onto deploy --install --commit
also leaves you on the deploy branch.