Skip to content
This repository
Browse code

History

  • Loading branch information...
commit 1a4a179e9a49120aa84a01500be2b1c744776842 1 parent 9200d3e
German Laullon authored
2  GLFileView.h
@@ -19,6 +19,7 @@
19 19
 	IBOutlet PBGitHistoryController* historyController;
20 20
 	IBOutlet MGScopeBar *typeBar;
21 21
 	NSMutableArray *groups;
  22
+	NSString *logFormat;
22 23
 }
23 24
 
24 25
 - (void)showFile;
@@ -26,5 +27,6 @@
26 27
 - (NSString *)parseBlame:(NSString *)txt;
27 28
 
28 29
 @property(retain) NSMutableArray *groups;
  30
+@property(retain) NSString *logFormat;
29 31
 
30 32
 @end
24  GLFileView.m
@@ -20,6 +20,11 @@ @implementation GLFileView
20 20
 
21 21
 - (void) awakeFromNib
22 22
 {
  23
+	NSString *formatFile = [[NSBundle mainBundle] pathForResource:@"format" ofType:@"html" inDirectory:@"html/views/log"];
  24
+	if(formatFile!=nil)
  25
+		logFormat=[NSString stringWithContentsOfURL:[NSURL fileURLWithPath:formatFile] encoding:NSUTF8StringEncoding error:nil];
  26
+	
  27
+	
23 28
 	startFile = @"fileview";
24 29
 	//repository = historyController.repository;
25 30
 	[super awakeFromNib];
@@ -36,6 +41,10 @@ - (void) awakeFromNib
36 41
 					   @"blame", ITEM_IDENTIFIER, 
37 42
 					   @"Blame", ITEM_NAME, 
38 43
 					   nil], 
  44
+					  [NSDictionary dictionaryWithObjectsAndKeys:
  45
+					   @"log", ITEM_IDENTIFIER, 
  46
+					   @"History", ITEM_NAME, 
  47
+					   nil], 
39 48
 					  nil];
40 49
 	[self.groups addObject:[NSDictionary dictionaryWithObjectsAndKeys:
41 50
 							[NSNumber numberWithBool:NO], GROUP_SEPARATOR, 
@@ -60,16 +69,24 @@ - (void) showFile
60 69
 		NSString *fileTxt=@"";
61 70
 		if(startFile==@"fileview")
62 71
 			fileTxt=[file textContents];
63  
-		if(startFile==@"blame")
  72
+		else if(startFile==@"blame")
64 73
 			fileTxt=[self parseBlame:[file blame]];
  74
+		else if(startFile==@"log")
  75
+			fileTxt=[file log:logFormat];
65 76
 
66 77
 		id script = [view windowScriptObject];
67 78
 		[script callWebScriptMethod:@"showFile" withArguments:[NSArray arrayWithObject:fileTxt]];
68 79
 	}
69 80
 }
70 81
 
71  
-#pragma mark MGScopeBarDelegate methods
  82
+#pragma mark JavaScript log.js methods
72 83
 
  84
+- (void) selectCommit:(NSString*)c
  85
+{
  86
+	[historyController selectCommit:[PBGitSHA shaWithString:c]];
  87
+}
  88
+
  89
+#pragma mark MGScopeBarDelegate methods
73 90
 
74 91
 - (int)numberOfGroupsInScopeBar:(MGScopeBar *)theScopeBar
75 92
 {
@@ -114,7 +131,7 @@ - (void)scopeBar:(MGScopeBar *)theScopeBar selectedStateChanged:(BOOL)selected f
114 131
 	startFile=identifier;
115 132
 	NSString *path = [NSString stringWithFormat:@"html/views/%@", identifier];
116 133
 	NSString *html = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:path];
117  
-	//NSLog(@"[FileViewerController scopeBar:selectedStateChanged] -> file: '%@' (%@)",html,identifier);
  134
+	NSLog(@"[FileViewerController scopeBar:selectedStateChanged] -> file: '%@' (%@)",html,identifier);
118 135
 	NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:html]];
119 136
 	[[view mainFrame] loadRequest:request];
120 137
 }
@@ -189,5 +206,6 @@ - (NSString *) parseBlame:(NSString *)txt
189 206
 }
190 207
 
191 208
 @synthesize groups;
  209
+@synthesize logFormat;
192 210
 
193 211
 @end
1  PBGitTree.h
@@ -28,6 +28,7 @@
28 28
 - (void) saveToFolder: (NSString *) directory;
29 29
 - (NSString *)textContents;
30 30
 - (NSString *)blame;
  31
+- (NSString *) log:(NSString *)format;
31 32
 
32 33
 - (NSString*) tmpFileNameForContents;
33 34
 - (long long)fileSize;
22  PBGitTree.m
@@ -119,7 +119,7 @@ - (NSString *) blame
119 119
 {
120 120
 	if (!leaf)
121 121
 		return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
122  
-
  122
+	
123 123
 	if ([self hasBinaryAttributes])
124 124
 		return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
125 125
 	
@@ -135,6 +135,26 @@ - (NSString *) blame
135 135
 	return contents;
136 136
 }
137 137
 
  138
+- (NSString *) log:(NSString *)format
  139
+{
  140
+	if (!leaf)
  141
+		return [NSString stringWithFormat:@"This is a tree with path %@", [self fullPath]];
  142
+	
  143
+	if ([self hasBinaryAttributes])
  144
+		return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
  145
+	
  146
+	if ([self fileSize] > 52428800) // ~50MB
  147
+		return [NSString stringWithFormat:@"%@ is too big to be displayed (%d bytes)", [self fullPath], [self fileSize]];
  148
+
  149
+	NSString *contents=[repository outputInWorkdirForArguments:[NSArray arrayWithObjects:@"log", [NSString stringWithFormat:@"--pretty=format:%@",format], @"--", [self fullPath], nil]];
  150
+	
  151
+	if ([self hasBinaryHeader:contents])
  152
+		return [NSString stringWithFormat:@"%@ appears to be a binary file of %d bytes", [self fullPath], [self fileSize]];
  153
+	
  154
+	
  155
+	return contents;
  156
+}
  157
+
138 158
 - (long long)fileSize
139 159
 {
140 160
 	if (_fileSize)
8  html/views/log/format.html
... ...
@@ -0,0 +1,8 @@
  1
+<div id='%h' class='commit'>
  2
+<p class="title">%s</p>
  3
+	<table>
  4
+		<tr><td>Author:</td><td>%an</td></tr>
  5
+		<tr><td>Date:</td><td>%ar</td></tr>
  6
+		<tr><td>Commit:</td><td><a href='' onclick='selectCommit(this.innerHTML);'>%H</a></td></tr>
  7
+	</table>
  8
+</div>
19  html/views/log/index.html
... ...
@@ -0,0 +1,19 @@
  1
+<html>
  2
+<head>
  3
+	<title>Details for commit</title>
  4
+	<link rel="stylesheet" href="../../css/GitX.css" type="text/css" media="screen" title="no title" charset="utf-8">
  5
+	<script src="../../lib/GitX.js" type="text/javascript" charset="utf-8"></script>
  6
+	<script src="../../lib/md5.js" type="text/javascript" charset="utf-8"></script>
  7
+	<script src="../../lib/diffHighlighter.js" type="text/javascript" charset="utf-8"></script>
  8
+	<script src="../../lib/keyboardNavigation.js" type="text/javascript" charset="utf-8"></script>
  9
+
  10
+	<link rel="stylesheet" href="log.css" type="text/css" media="screen" title="no title" charset="utf-8">
  11
+	<script src="log.js" type="text/javascript" charset="utf-8"></script>
  12
+</head>
  13
+
  14
+<body>
  15
+	<div id="message" style="display:none">
  16
+		There are no differences
  17
+	</div>
  18
+	<div id='log'></div>
  19
+</body>
12  html/views/log/log.css
... ...
@@ -0,0 +1,12 @@
  1
+.commit table tr td:nth-of-type(1){
  2
+	text-align: right;
  3
+	color: gray;
  4
+}
  5
+
  6
+.commit{
  7
+	margin: 10px;
  8
+	padding: 10px;
  9
+	border-radius: 10px;
  10
+	border: 1px solid #CCC;
  11
+	-webkit-box-shadow: 1px 1px 2px #DDD;
  12
+}
10  html/views/log/log.js
... ...
@@ -0,0 +1,10 @@
  1
+var selectCommit = function(a) {
  2
+	window.Controller.selectCommit_(a);
  3
+	return false;
  4
+}
  5
+
  6
+var showFile = function(txt) {
  7
+	$("log").style.display = "";
  8
+	$("log").innerHTML=txt;
  9
+	return;
  10
+}
200  html/views/log/test.html
... ...
@@ -0,0 +1,200 @@
  1
+<html><head>
  2
+	<title>Details for commit</title>
  3
+	<link rel="stylesheet" href="../../css/GitX.css" type="text/css" media="screen" title="no title" charset="utf-8">
  4
+	<script src="../../lib/GitX.js" type="text/javascript" charset="utf-8"></script>
  5
+	<script src="../../lib/md5.js" type="text/javascript" charset="utf-8"></script>
  6
+	<script src="../../lib/diffHighlighter.js" type="text/javascript" charset="utf-8"></script>
  7
+	<script src="../../lib/keyboardNavigation.js" type="text/javascript" charset="utf-8"></script>
  8
+
  9
+	<link rel="stylesheet" href="log.css" type="text/css" media="screen" title="no title" charset="utf-8">
  10
+	<script src="log.js" type="text/javascript" charset="utf-8"></script>
  11
+
  12
+	<script type="text/javascript" charset="utf-8">
  13
+		var showDiff = function(diff) {
  14
+			highlightDiff(diff, $("diff"));
  15
+		}
  16
+	</script>
  17
+</head><body>
  18
+	<div id="message" style="display:none">
  19
+		There are no differences
  20
+	</div>
  21
+	<div id="log"><div id="7037821" class="commit">
  22
+	<table>
  23
+		<tbody><tr><td>Commit:</td><td>703782163ddb653789c304e396eadb31f541864f</td></tr>
  24
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  25
+		<tr><td>Date:</td><td>10 months ago</td></tr>
  26
+	</tbody></table>
  27
+	<div class="title">PBChangedFile: Add assert to make sure we're not doing something stupid</div>
  28
+	<div class="body"></div>
  29
+</div>
  30
+
  31
+<div id="0d8ba8c" class="commit">
  32
+	<table>
  33
+		<tbody><tr><td>Commit:</td><td>0d8ba8c2632e129fe7627f86d907c8b470c1bf20</td></tr>
  34
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  35
+		<tr><td>Date:</td><td>1 year, 1 month ago</td></tr>
  36
+	</tbody></table>
  37
+	<div class="title">Rename 'CachedChanges" to "StagedChanges" for greater consistency</div>
  38
+	<div class="body"></div>
  39
+</div>
  40
+
  41
+<div id="f9ff15c" class="commit">
  42
+	<table>
  43
+		<tbody><tr><td>Commit:</td><td>f9ff15cc6bf3c807425321581002f676985dd222</td></tr>
  44
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  45
+		<tr><td>Date:</td><td>1 year, 1 month ago</td></tr>
  46
+	</tbody></table>
  47
+	<div class="title">PBChangedFile: remove shouldBeDeleted boolean</div>
  48
+	<div class="body">We don't need this anymore</div>
  49
+</div>
  50
+
  51
+<div id="8d729da" class="commit">
  52
+	<table>
  53
+		<tbody><tr><td>Commit:</td><td>8d729dae4cc8d3b564d149d6c9bb96922ee1bafa</td></tr>
  54
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  55
+		<tr><td>Date:</td><td>1 year, 6 months ago</td></tr>
  56
+	</tbody></table>
  57
+	<div class="title">CommitView: Don't change selection when refreshing</div>
  58
+	<div class="body">We used to read in a completely new array when refreshing
  59
+the index. The problem with this is that the selection
  60
+changes when reading in the new array. We avoid this
  61
+by changing the current array, rather than loading in
  62
+a completely new one.</div>
  63
+</div>
  64
+
  65
+<div id="0975426" class="commit">
  66
+	<table>
  67
+		<tbody><tr><td>Commit:</td><td>0975426f2f5119335c00768006b1ede0252ac448</td></tr>
  68
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  69
+		<tr><td>Date:</td><td>2 years, 7 months ago</td></tr>
  70
+	</tbody></table>
  71
+	<div class="title">CommitView: move index functions to separate controller</div>
  72
+	<div class="body">This merges functionality that was previously stored in the
  73
+combination of PBGitCommitController / PBChangedFile to a
  74
+dedicated controller, PBGitIndexController.
  75
+</div>
  76
+</div>
  77
+
  78
+<div id="1d19bd6" class="commit">
  79
+	<table>
  80
+		<tbody><tr><td>Commit:</td><td>1d19bd64dfa83def18d5271c9afef9300ef0d65e</td></tr>
  81
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  82
+		<tr><td>Date:</td><td>2 years, 8 months ago</td></tr>
  83
+	</tbody></table>
  84
+	<div class="title">PBChangedFile: Don't use cat to read file contents</div>
  85
+	<div class="body">This changes PBChangedFile to read in files by using
  86
+NSString's stringWithContentsOfFile: method.
  87
+
  88
+It still uses the UTF8 encoding scheme so that we
  89
+can capture binary files. This should perhaps be loosened to
  90
+also allow other encodings.
  91
+</div>
  92
+</div>
  93
+
  94
+<div id="472d36c" class="commit">
  95
+	<table>
  96
+		<tbody><tr><td>Commit:</td><td>472d36c7f970d9f3dbda3b9d7c8a7d51546bda56</td></tr>
  97
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  98
+		<tr><td>Date:</td><td>2 years, 8 months ago</td></tr>
  99
+	</tbody></table>
  100
+	<div class="title">CommitView: Add context menu to revert changes</div>
  101
+	<div class="body"></div>
  102
+</div>
  103
+
  104
+<div id="e659e63" class="commit">
  105
+	<table>
  106
+		<tbody><tr><td>Commit:</td><td>e659e63fc08ecd46cc1c26b6260126502ec656aa</td></tr>
  107
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  108
+		<tr><td>Date:</td><td>2 years, 8 months ago</td></tr>
  109
+	</tbody></table>
  110
+	<div class="title">CommitView: Add option to amend commits</div>
  111
+	<div class="body"></div>
  112
+</div>
  113
+
  114
+<div id="5010511" class="commit">
  115
+	<table>
  116
+		<tbody><tr><td>Commit:</td><td>5010511bdb358ad376fd4668368bc5c12d9d8214</td></tr>
  117
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  118
+		<tr><td>Date:</td><td>2 years, 8 months ago</td></tr>
  119
+	</tbody></table>
  120
+	<div class="title">CommitView: Always use a single PBChangedFile object</div>
  121
+	<div class="body">This makes sure we don't add a double object to our array,
  122
+if a file has both cached and unstaged changes.
  123
+</div>
  124
+</div>
  125
+
  126
+<div id="a0f248e" class="commit">
  127
+	<table>
  128
+		<tbody><tr><td>Commit:</td><td>a0f248ef9f50a3af0efebdfb29c706bd97011a97</td></tr>
  129
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  130
+		<tr><td>Date:</td><td>2 years, 8 months ago</td></tr>
  131
+	</tbody></table>
  132
+	<div class="title">CommitView: Also show deleted files correctly</div>
  133
+	<div class="body"></div>
  134
+</div>
  135
+
  136
+<div id="001b6bf" class="commit">
  137
+	<table>
  138
+		<tbody><tr><td>Commit:</td><td>001b6bf10eeaaf618971bc079e7415690c4c8d1a</td></tr>
  139
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  140
+		<tr><td>Date:</td><td>2 years, 9 months ago</td></tr>
  141
+	</tbody></table>
  142
+	<div class="title">CommitView: Handle new files better</div>
  143
+	<div class="body">This fixes the 'cat' command that was acting up and also shows
  144
+information when a file could not be displayed</div>
  145
+</div>
  146
+
  147
+<div id="aafc284" class="commit">
  148
+	<table>
  149
+		<tbody><tr><td>Commit:</td><td>aafc284eb8fbd69acf40acfef07e25f409a87a18</td></tr>
  150
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  151
+		<tr><td>Date:</td><td>2 years, 9 months ago</td></tr>
  152
+	</tbody></table>
  153
+	<div class="title">ChangedFile: add a path separator to reset command</div>
  154
+	<div class="body">Sometimes a file could not be reset because it contained weird characters.
  155
+
  156
+This hopefully fixes it.
  157
+</div>
  158
+</div>
  159
+
  160
+<div id="76e176e" class="commit">
  161
+	<table>
  162
+		<tbody><tr><td>Commit:</td><td>76e176e8b4ac59438340b129874ffbdfa7404ea3</td></tr>
  163
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  164
+		<tr><td>Date:</td><td>2 years, 9 months ago</td></tr>
  165
+	</tbody></table>
  166
+	<div class="title">Add staging and unstaging of files</div>
  167
+	<div class="body"></div>
  168
+</div>
  169
+
  170
+<div id="9b3909e" class="commit">
  171
+	<table>
  172
+		<tbody><tr><td>Commit:</td><td>9b3909e7592d3c8648accb67642a2b57a441f128</td></tr>
  173
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  174
+		<tr><td>Date:</td><td>2 years, 9 months ago</td></tr>
  175
+	</tbody></table>
  176
+	<div class="title">CommitView: Add a status bar to the diff view</div>
  177
+	<div class="body"></div>
  178
+</div>
  179
+
  180
+<div id="44009b6" class="commit">
  181
+	<table>
  182
+		<tbody><tr><td>Commit:</td><td>44009b6f3e7e6fc5b54910c2b2a9a54b13f95a14</td></tr>
  183
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  184
+		<tr><td>Date:</td><td>2 years, 9 months ago</td></tr>
  185
+	</tbody></table>
  186
+	<div class="title">CommitView: use only one array for all files</div>
  187
+	<div class="body"></div>
  188
+</div>
  189
+
  190
+<div id="252796e" class="commit">
  191
+	<table>
  192
+		<tbody><tr><td>Commit:</td><td>252796ee26ce733c4a6d3044e3142f9ee5df005e</td></tr>
  193
+		<tr><td>Author:</td><td>Pieter de Bie</td></tr>
  194
+		<tr><td>Date:</td><td>2 years, 9 months ago</td></tr>
  195
+	</tbody></table>
  196
+	<div class="title">CommitView: Show basic files</div>
  197
+	<div class="body"></div>
  198
+</div></div>
  199
+
  200
+</body></html>

0 notes on commit 1a4a179

Please sign in to comment.
Something went wrong with that request. Please try again.