public
Description: Append short Git revision to CFBundleVersion in Info.plist
Homepage: http://stateful.net
Clone URL: git://github.com/statefullabs/git-bundle-version.git
mgrimes (author)
Sun Feb 22 01:41:35 -0800 2009
commit  2c9b37b92a9bd4606f718ad02cfcefa2eb0e63af
tree    868b5011a42e099b23d5b3f80352c8f30b135fb5
parent  3b2f61576ac075aeb208757ba66948d3e936fd9b
git-bundle-version / git-bundle-version.rb
100644 25 lines (20 sloc) 0.613 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# git-bundle-version.rb - Append short Git revision to CFBundleVersion in Info.plist
#
# THIS SCRIPT EXPECTS TO BE RUN FROM XCODE AS A RUN SCRIPT PHASE TO A BUILD TARGET
#
# Copyright 2008-2009 Stateful Labs <mark@stateful.net>
# All rights reserved.
 
require 'fileutils'
 
# Specify path to git executable
git_bin = "/usr/local/bin/git"
 
rev = `#{git_bin} rev-parse --short HEAD`.gsub("\n","")
file = "#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['INFOPLIST_PATH']}"
 
File.open(file, 'r+') do |f|
  lines = f.readlines
  lines.each do |it|
    it.gsub!(/GIT/, rev)
  end
  f.pos = 0
  f.print lines
  f.truncate(f.pos)
end