public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/dustin/gitnub.git
Search Repo:
Got mercurial working in addition to git.
dustin (author)
Fri Mar 14 22:12:21 -0700 2008
commit  8048872c76a0bdc44eb2a5855689106fc9082d67
tree    c97a6be805f1a17c303ef049ca03e4c728e333e6
parent  f7e8c6cf6273967d8f7237c828e4c86e036949bc
...
10
11
12
13
14
 
15
16
17
...
40
41
42
43
44
 
 
 
45
46
47
...
10
11
12
 
13
14
15
16
17
...
40
41
42
 
 
43
44
45
46
47
48
0
@@ -10,8 +10,8 @@
0
 require 'pathname'
0
 require 'osx/cocoa'
0
 require 'mime-types/lib/mime/types'
0
-require 'grit/lib/grit'
0
 require 'lib/time_extensions'
0
+require 'lib/rcsetta'
0
 require 'InfoWindowController'
0
 
0
 OSX.ns_import 'CommitSummaryCell'
0
@@ -40,8 +40,9 @@
0
     return true
0
   end
0
   
0
- def awakeFromNib
0
- repo
0
+ def awakeFromNib
0
+ @repo = RCSetta::open(REPOSITORY_LOCATION)
0
+
0
     @window.delegate = self
0
     column = @commits_table.tableColumns[0]
0
     cell = CommitSummaryCell.alloc.init
...
228
229
230
231
232
233
234
235
 
236
237
238
...
228
229
230
 
 
 
 
 
231
232
233
234
0
@@ -228,11 +228,7 @@
0
   end
0
   
0
   def fetch_git_repository
0
- begin
0
- @repo = Grit::Repo.new(REPOSITORY_LOCATION)
0
- rescue Grit::InvalidGitRepositoryError
0
- return false
0
- end
0
+ @repo = RCSetta::open REPOSITORY_LOCATION
0
   end
0
   
0
   def fetch_commits_for(branch, quanity, offset = 0)
...
255
256
257
258
259
 
260
261
262
...
255
256
257
 
258
259
260
261
262
0
@@ -255,8 +255,8 @@
0
       isa = PBXResourcesBuildPhase;
0
       buildActionMask = 2147483647;
0
       files = (
0
-        4DDCA7070ACC9A6100E082CE /* InfoPlist.strings in Resources */,
0
         4DDCA7080ACC9A6100E082CE /* rb_main.rb in Resources */,
0
+        4DDCA7070ACC9A6100E082CE /* InfoPlist.strings in Resources */,
0
         288853050D7CE2E500862D67 /* LICENSE in Resources */,
0
         2888530D0D7CEA5200862D67 /* gitnub-icon.icns in Resources */,
0
         288853C90D7E06A600862D67 /* commit.html in Resources */,
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
0
@@ -1 +1,113 @@
0
+require 'grit/lib/grit'
0
+
0
+module RCSetta
0
+
0
+ class HGBranch
0
+
0
+ attr_accessor :name
0
+
0
+ def initialize(n)
0
+ self.name=n
0
+ end
0
+
0
+ def inspect
0
+ %Q{#<HGBranch "#{name}>}
0
+ end
0
+
0
+ end
0
+
0
+ class HGCommit
0
+
0
+ attr_reader :id
0
+ attr_reader :parents
0
+ attr_reader :tree
0
+ attr_reader :author
0
+ attr_reader :authored_date
0
+ attr_reader :committer
0
+ attr_reader :committed_date
0
+ attr_reader :message
0
+ attr_reader :short_message
0
+
0
+ def initialize(repo, node, author, branches, parents, date, summary, msg)
0
+ @repo=repo
0
+ @id=node
0
+ @author=::Grit::Actor.from_string author
0
+ @authored_date = Time.at date.to_i
0
+ @committer=self.author
0
+ @committed_date = self.authored_date
0
+ @short_message = summary
0
+ @message = msg
0
+
0
+ @parents=[]
0
+ end
0
+
0
+ def diffs
0
+ diff = @repo.run_cmd %W(export -g #{@id})
0
+ if diff =~ /diff --git a/
0
+ diff = diff.sub(/.+?(diff --git a)/m, '\1')
0
+ else
0
+ diff = ''
0
+ end
0
+ ::Grit::Diff.list_from_string(@repo, diff)
0
+ end
0
+
0
+ end
0
+
0
+ class HGRepo
0
+
0
+ attr_accessor :path
0
+
0
+ # This is a terrible hack -- I couldn't get nulls working correctly
0
+ FSEP='892af' + '675f7'
0
+ LSEP='7dff7' + 'f5263'
0
+
0
+ FIELDS=%w(node author branches parents date desc|firstline desc)
0
+
0
+ COMMIT_TEMPL=FIELDS.map{|i| "{#{i}}"}.join(FSEP) + LSEP
0
+ COMMIT_TEMPL_Q=%{"#{COMMIT_TEMPL}"}
0
+
0
+ def initialize(path)
0
+ self.path=path
0
+ end
0
+
0
+ def inspect
0
+ %Q{#<HGRepo "#{@path}>"}
0
+ end
0
+
0
+ def branches
0
+ [HGBranch.new('default')]
0
+ end
0
+
0
+ def commit_count(start='default')
0
+ (run_cmd %W(id -n)).to_i
0
+ end
0
+
0
+ def commits(start = 'master', max_count = 10, skip = 0)
0
+ start = 'default' if start.to_s == 'master'
0
+ l=run_cmd ['log', '-l', (max_count + skip), '--template', COMMIT_TEMPL_Q]
0
+ l.split(LSEP).last(max_count).map{|i| HGCommit.new(self, *i.split(FSEP))}
0
+ end
0
+
0
+ def run_cmd(cmd)
0
+ c = (%W(hg -R #{self.path}) + cmd).join(' ')
0
+ `#{c}`
0
+ end
0
+
0
+ end
0
+
0
+ SCM_DRIVERS = { '.hg' => HGRepo, '.git' => ::Grit::Repo }
0
+
0
+ # Detect a repo type and open it.
0
+ def RCSetta::open(path)
0
+ epath = File.expand_path path
0
+
0
+ driver = SCM_DRIVERS.detect{|p, c| File.exist?(File.join(epath, p))}
0
+ if driver
0
+ driver.last.new epath
0
+ else
0
+ raise "Cannot detect repo type from #{path}"
0
+ end
0
+ end
0
+
0
+end

Comments

    No one has commented yet.