How do you prevent Git from printing 'remote:' on each line of the output of a post-recieve hook?
I recently configured an EC2 instance with a Git deployment workflow that resembles Heroku, but I can't seem to figure out how Heroku prevents the Git post-receive hook from outputting 'remote:' on each line.
Consider the following two examples (one from my EC2 project and one from a Heroku project):
My EC2 project:
git push prod master
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 456 bytes, done.
Total 5 (delta 3), reused 0 (delta 0)
remote:
remote: Receiving push
remote: Deploying updated files (by resetting HEAD)
remote: HEAD is now at bf17da8 test commit
remote: Running bundler to install gem dependencies
remote: Fetching source index for http://rubygems.org/
remote: Installing rake (0.8.7)
remote: Installing abstract (1.0.0)
...
remote: Installing railties (3.0.0)
remote: Installing rails (3.0.0)
remote: Your bundle is complete! It was installed into ./.bundle/gems
remote: Launching (by restarting Passenger)... done
remote:
To ssh://ubuntu@0.0.0.0/~/apps/app_name
e8bd06f..bf17da8 master -> master
Heroku:
$> git push heroku master
Counting object开发者_开发百科s: 179, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (89/89), done.
Writing objects: 100% (105/105), 42.70 KiB, done.
Total 105 (delta 53), reused 0 (delta 0)
-----> Heroku receiving push
-----> Rails app detected
-----> Gemfile detected, running Bundler version 1.0.3
Unresolved dependencies detected; Installing...
Using --without development:test
Fetching source index for http://rubygems.org/
Installing rake (0.8.7)
Installing abstract (1.0.0)
...
Installing railties (3.0.0)
Installing rails (3.0.0)
Your bundle is complete! It was installed into ./.bundle/gems
Compiled slug size is 4.8MB
-----> Launching... done
http://your_app_name.heroku.com deployed to Heroku
To git@heroku.com:your_app_name.git
3bf6e8d..642f01a master -> master
Is it possible that Heroku is emitting terminal control codes that overwrite the "remote:" prefix on each line? Something like "\e[1G-----> line"
Not certain why nobody seems to take advantage of $'\e[K'
(erase to end of line) to avoid the need to indent.
echo $'\e[1G\e[K'line
does the same thing without needing any indentation to ensure the remote:
string (which is actually output by the git client, not the hook itself) doesn't get displayed.
Granted, this doesn't explain how Heroku, specifically, pulls this off, but that doesn't appear to have been the actual question - rather, Heroku seems to have been used as an example of someone doing what the OP was after.
精彩评论