Module: Buildr::Hg
- Defined in:
- lib/buildr/core/build.rb
Overview
:nodoc:
Class Method Summary collapse
-
.commit(file, message) ⇒ Object
Commit the given file with a message.
-
.current_branch ⇒ Object
Return the name of the current local branch or nil if none.
-
.hg(*args) ⇒ Object
:call-seq: hg(*args).
-
.push ⇒ Object
Update the remote branch with the local commits This will push the current remote destination and current branch.
-
.remote ⇒ Object
Return the aliases (if any) of any remote repositories which the current local branch tracks.
-
.uncommitted_files ⇒ Object
Return a list of uncommitted / untracked files as reported by hg status The codes used to show the status of files are: M = modified A = added R = removed C = clean ! = missing (deleted by non-hg command, but still tracked) ? = not tracked I = ignored = origin of the previous file listed as A (added).
Class Method Details
.commit(file, message) ⇒ Object
Commit the given file with a message. The file should already be added to the Mercurial index.
111 112 113 |
# File 'lib/buildr/core/build.rb', line 111 def commit(file, ) hg 'commit', '-m', , file end |
.current_branch ⇒ Object
Return the name of the current local branch or nil if none.
122 123 124 |
# File 'lib/buildr/core/build.rb', line 122 def current_branch hg('branch').to_s.strip end |
.hg(*args) ⇒ Object
:call-seq:
hg(*args)
Executes a Mercurial (hg) command passing through the args and returns the output. Throws exception if the exit status is not zero. For example:
hg 'commit'
hg 'update', 'default'
89 90 91 92 93 94 |
# File 'lib/buildr/core/build.rb', line 89 def hg(*args) cmd = "hg #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}" output = `#{cmd}` fail "Mercurial command \"#{cmd}\" failed with status #{$?.exitstatus}\n#{output}" unless $?.exitstatus == 0 return output end |
.push ⇒ Object
Update the remote branch with the local commits This will push the current remote destination and current branch.
117 118 119 |
# File 'lib/buildr/core/build.rb', line 117 def push hg 'push' end |
.remote ⇒ Object
Return the aliases (if any) of any remote repositories which the current local branch tracks
127 128 129 |
# File 'lib/buildr/core/build.rb', line 127 def remote hg('paths').scan(/^(?:default|default-push)\s+=\s+(\S.*)/).map{ |match| match.last } end |
.uncommitted_files ⇒ Object
Return a list of uncommitted / untracked files as reported by hg status The codes used to show the status of files are:
M = modified
A = added
R = removed
C = clean
! = missing (deleted by non-hg command, but still tracked)
? = not tracked
I = ignored
= origin of the previous file listed as A (added)
106 107 108 |
# File 'lib/buildr/core/build.rb', line 106 def uncommitted_files `hg status`.scan(/^(A|M|R|!|\?) (\S.*)$/).map{ |match| match.last.split.last } end |