Class: HGTK::Repo
- Inherits:
-
Object
- Object
- HGTK::Repo
- Defined in:
- lib/hgtk/repo.rb
Overview
A Mercurial repository.
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
TODO: Swap out for an existing Hg API?.
Instance Method Summary collapse
-
#incoming ⇒ Object
Check for incoming changesets.
-
#initialize(**kwargs) ⇒ Repo
constructor
A new instance of Repo.
- #is_repo? ⇒ Boolean
-
#outgoing ⇒ Object
Check for outgoing changesets.
-
#pull(update: false) ⇒ Object
Pull incoming changesets.
-
#push(force: false) ⇒ Object
Push outgoing changesets.
-
#status ⇒ Object
Check repo status (uncommitted changes).
-
#sync ⇒ Object
Synchronize repository by pulling, then pushing.
Constructor Details
#initialize(**kwargs) ⇒ Repo
Returns a new instance of Repo.
13 14 15 |
# File 'lib/hgtk/repo.rb', line 13 def initialize **kwargs @dir = kwargs.fetch :dir, Dir.pwd end |
Instance Attribute Details
#dir ⇒ Object (readonly)
TODO: Swap out for an existing Hg API?
8 9 10 |
# File 'lib/hgtk/repo.rb', line 8 def dir @dir end |
Instance Method Details
#incoming ⇒ Object
Check for incoming changesets.
28 29 30 31 |
# File 'lib/hgtk/repo.rb', line 28 def incoming repo_check command 'incoming' end |
#is_repo? ⇒ Boolean
17 18 19 |
# File 'lib/hgtk/repo.rb', line 17 def is_repo? Dir.exists? "#{@dir}/.hg" end |
#outgoing ⇒ Object
Check for outgoing changesets.
34 35 36 37 |
# File 'lib/hgtk/repo.rb', line 34 def outgoing repo_check command 'outgoing' end |
#pull(update: false) ⇒ Object
Pull incoming changesets.
40 41 42 43 44 45 |
# File 'lib/hgtk/repo.rb', line 40 def pull update: false repo_check cmd = 'incoming' cmd += ' -u' if update command cmd end |
#push(force: false) ⇒ Object
Push outgoing changesets.
48 49 50 51 52 53 |
# File 'lib/hgtk/repo.rb', line 48 def push force: false repo_check cmd = 'outgoing' cmd += ' -f' if force command cmd end |
#status ⇒ Object
Check repo status (uncommitted changes).
22 23 24 25 |
# File 'lib/hgtk/repo.rb', line 22 def status repo_check command 'st' end |
#sync ⇒ Object
Synchronize repository by pulling, then pushing.
56 57 58 59 60 |
# File 'lib/hgtk/repo.rb', line 56 def sync repo_check pull push end |