<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <link>http://persumi.com/u/fredwu/tech/e/blog/t/git</link>
    <generator>Persumi - Level up your writing and blogging with AI</generator>
    <category>Blog</category>
    <category>Tech</category>
    <pubDate>Fri, 01 May 2026 13:37:49 +0000</pubDate>
    <description/>
    <title>Blog (git) - Fred Wu&apos;s Tech</title>
    <atom:link type="application/rss+xml" rel="self" href="http://persumi.com/u/fredwu/tech/e/blog/t/git/feed/rss"></atom:link>
    <item>
      <pubDate>Tue, 13 Nov 2012 07:34:00 +0000</pubDate>
      <guid>http://persumi.com/u/fredwu/tech/e/blog/p/simplecov-test-coverage-for-changed-files-only</guid>
      <comments>http://persumi.com/u/fredwu/tech/e/blog/p/simplecov-test-coverage-for-changed-files-only</comments>
      <category>Blog</category>
      <category>Tech</category>
      <author>ifredwu@gmail.com (Fred Wu)</author>
      <description>&lt;![CDATA[&lt;p&gt;
The other day a colleague asked whether or not it’s possible to have &lt;a href=&quot;https://github.com/colszowka/simplecov&quot;&gt;SimpleCov&lt;/a&gt; return a group that only contains uncommitted changes.&lt;/p&gt;
&lt;p&gt;
The answer is &lt;strong&gt;yes&lt;/strong&gt;! After some digging around, we found the following way:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby language-ruby&quot;&gt;# in spec_helper.rb
SimpleCov.start &apos;rails&apos; do
  add_group &apos;Changed&apos; do |source_file|
    `git ls-files --exclude-standard --others \
      &amp;&amp; git diff --name-only \
      &amp;&amp; git diff --name-only --cached`.split(&quot;\n&quot;).detect do |filename|
      source_file.filename.ends_with?(filename)
    end
  end
end&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Basically use &lt;code class=&quot;inline&quot;&gt;git ls-files --exclude-standard --others&lt;/code&gt; for untracked files, &lt;code class=&quot;inline&quot;&gt;git diff --name-only&lt;/code&gt; for unstaged files and &lt;code class=&quot;inline&quot;&gt;git diff --name-only --cached&lt;/code&gt; for staged files.&lt;/p&gt;
]]&gt;</description>
      <link>http://persumi.com/u/fredwu/tech/e/blog/p/simplecov-test-coverage-for-changed-files-only</link>
      <title>SimpleCov: Test Coverage for Changed Files Only</title>
    </item>
    <item>
      <pubDate>Mon, 21 Jun 2010 04:45:00 +0000</pubDate>
      <guid>http://persumi.com/u/fredwu/tech/e/blog/p/deploy-php-websites-using-capistrano-and-git</guid>
      <comments>http://persumi.com/u/fredwu/tech/e/blog/p/deploy-php-websites-using-capistrano-and-git</comments>
      <category>Blog</category>
      <category>Tech</category>
      <author>ifredwu@gmail.com (Fred Wu)</author>
      <description>&lt;![CDATA[&lt;p&gt;
The &lt;a href=&quot;http://rubyonrails.org/&quot;&gt;Rails&lt;/a&gt; deployment flow is really smooth thanks to the powerful (and easy to use) &lt;a href=&quot;http://www.capify.org/&quot;&gt;Capistrano&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Capistrano not only works with Rails and other Ruby code bases, but also code bases in any programming languages, such as &lt;a href=&quot;http://php.net/&quot;&gt;PHP&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;
Here is an overview of what I did to get one of our PHP production sites up and running with Capistrano.&lt;/p&gt;
&lt;p&gt;
If you don’t already have &lt;a href=&quot;http://www.ruby-lang.org/en/&quot;&gt;Ruby&lt;/a&gt; and &lt;a href=&quot;http://rubygems.org/&quot;&gt;Rubygems&lt;/a&gt; installed, install them!&lt;/p&gt;
&lt;p&gt;
After you got &lt;code class=&quot;inline&quot;&gt;ruby&lt;/code&gt; and &lt;code class=&quot;inline&quot;&gt;rubygems&lt;/code&gt;, install Capistrano and its related gems -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;gem install capistrano-ext railsless-deploy&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Now, navigate to your application’s directory and run &lt;code class=&quot;inline&quot;&gt;capify .&lt;/code&gt;, this will generate some necessary files for Capistrano to recognise your app.&lt;/p&gt;
&lt;p&gt;
Open up the generated &lt;code class=&quot;inline&quot;&gt;Capfile&lt;/code&gt; file and replace the content of the file with:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby language-ruby&quot;&gt;require &apos;rubygems&apos;
require &apos;railsless-deploy&apos;
load &apos;config/deploy&apos;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Okay, now we need to set up the actual deployment recipe in the &lt;code class=&quot;inline&quot;&gt;config/deploy.rb&lt;/code&gt; file. But before doing so, we need to set up our deployment server with proper user and deployment permission.&lt;/p&gt;
&lt;p&gt;
We chose to set up a new user called &lt;code class=&quot;inline&quot;&gt;deploy&lt;/code&gt; specifically for deployment purpose, for example -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;useradd deploy&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Then of course, we need the SSH keys for this deployment user, so switch to this user (&lt;code class=&quot;inline&quot;&gt;su deploy&lt;/code&gt;) and -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;ssh-keygen&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
We use &lt;a href=&quot;http://github.com/&quot;&gt;GitHub&lt;/a&gt;, so simply copy the content of the public key (&lt;code class=&quot;inline&quot;&gt;~/.ssh/id_rsa.pub&lt;/code&gt;) and add it to the deploy keys section of the Github repository.&lt;/p&gt;
&lt;p&gt;
Don’t forget to also add GitHub to the &lt;code class=&quot;inline&quot;&gt;.ssh/known_hosts&lt;/code&gt; file, you can do this by manually cloning your repository on the deployment server.&lt;/p&gt;
&lt;p&gt;
Great! Now let’s do the last step - create the actual deployment recipe!&lt;/p&gt;
&lt;p&gt;
Open up &lt;code class=&quot;inline&quot;&gt;config/deploy.rb&lt;/code&gt; file and you will see some default deployment tasks. Everyone has different needs, so I’m going to paste our &lt;code class=&quot;inline&quot;&gt;deploy.rb&lt;/code&gt; file (masked with added comments) for your reference.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby language-ruby&quot;&gt;set :user, &quot;deploy&quot;
set :application, &quot;YOUR_APPLICATION_NAME&quot;
set :domain, &quot;YOUR_APPLICATION_DOMAIN_NAME&quot;
set :repository, &quot;THE_ADDRESS_OF_THE_APPLICATION_REPOSITORY&quot;
set :deploy_to, &quot;/var/www/#{domain}&quot;
set :shared_path, &quot;#{deploy_to}/shared&quot;
set :use_sudo, false

set :scm, :git
set :branch, &apos;master&apos;
set :deploy_via, :remote_cache

role :web, &quot;ADDRESS_OF_YOUR_WEB_SERVER&quot;
role :app, &quot;ADDRESS_OF_YOUR_APP_SERVER&quot; # this can be the same as the web server
role :db, &quot;ADDRESS_OF_YOUR_DB_SERVER&quot;, :primary =&gt; true # this can be the same as the web server

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do
  run &quot;#{try_sudo} /etc/init.d/lsws reload&quot; # we use LiteSpeed Web Server
  end
end

# The task below serves the purpose of creating symlinks for asset files.
# Large asset files like user uploaded contents and images should not be checked into the repository anyway, so you should move them to a shared location.

task :create_symlinks, :roles =&gt; :web do
  run &quot;ln -s #{shared_path}/uploads #{current_release}/uploads&quot;
  run &quot;ln -s #{shared_path}/zb #{current_release}/zb&quot;
end

# Let&apos;s run the task immediately after the deployment is finalised.

after &quot;deploy:finalize_update&quot;, :create_symlinks&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
That’s it! Now you should be able to deploy your application by -&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;shell language-shell&quot;&gt;cap deploy:setup
cap deploy&lt;/code&gt;&lt;/pre&gt;
]]&gt;</description>
      <link>http://persumi.com/u/fredwu/tech/e/blog/p/deploy-php-websites-using-capistrano-and-git</link>
      <title>Deploy PHP Websites Using Capistrano (and Git)</title>
    </item>
  </channel>
</rss>