Skip to content

Commit

Permalink
Merge pull request #17 from 00Davo/show-author-date
Browse files Browse the repository at this point in the history
Display both author and committer dates in Quick View
  • Loading branch information
swisspol committed Oct 1, 2015
2 parents 602d0ae + 9cc8d68 commit 3a6edc0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 27 deletions.
2 changes: 2 additions & 0 deletions GitUpKit/Core/GCCommit.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
@property(nonatomic, readonly) NSTimeZone* timeZone;
@property(nonatomic, readonly) NSString* authorName;
@property(nonatomic, readonly) NSString* authorEmail;
@property(nonatomic, readonly) NSDate* authorDate;
@property(nonatomic, readonly) NSString* committerName;
@property(nonatomic, readonly) NSString* committerEmail;
@property(nonatomic, readonly) NSDate* committerDate;
@property(nonatomic, readonly) NSString* treeSHA1;
@end

Expand Down
15 changes: 12 additions & 3 deletions GitUpKit/Core/GCCommit.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ - (NSString*)summary {
return _ConvertMessage(self, summary, strlen(summary), git_commit_message_encoding((git_commit*)_private));
}

// Reimplementation of git_commit_time()
- (NSDate*)date {
const git_signature* signature = git_commit_committer((git_commit*)_private);
return [NSDate dateWithTimeIntervalSince1970:signature->when.time];
return self.committerDate;
}

// Reimplementation of git_commit_time_offset()
Expand All @@ -85,6 +83,11 @@ - (NSString*)authorEmail {
return [NSString stringWithUTF8String:signature->email];
}

- (NSDate*)authorDate {
const git_signature* signature = git_commit_author((git_commit*)_private);
return [NSDate dateWithTimeIntervalSince1970:signature->when.time];
}

- (NSString*)committerName {
const git_signature* signature = git_commit_committer((git_commit*)_private);
return [NSString stringWithUTF8String:signature->name];
Expand All @@ -95,6 +98,12 @@ - (NSString*)committerEmail {
return [NSString stringWithUTF8String:signature->email];
}

// Reimplementation of git_commit_time()
- (NSDate*)committerDate {
const git_signature* signature = git_commit_committer((git_commit*)_private);
return [NSDate dateWithTimeIntervalSince1970:signature->when.time];
}

- (NSString*)treeSHA1 {
return GCGitOIDToSHA1(git_commit_tree_id((git_commit*)_private));
}
Expand Down
11 changes: 7 additions & 4 deletions GitUpKit/Views/GIQuickViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ @interface GIQuickViewController () <GIDiffContentsViewControllerDelegate, GIDif
@property(nonatomic, weak) IBOutlet NSView* infoView;
@property(nonatomic, weak) IBOutlet NSScrollView* infoScrollView;
@property(nonatomic, weak) IBOutlet NSTextField* sha1TextField;
@property(nonatomic, weak) IBOutlet NSTextField* dateTextField;
@property(nonatomic, weak) IBOutlet NSTextField* messageTextField;
@property(nonatomic, weak) IBOutlet NSTextField* authorTextField;
@property(nonatomic, weak) IBOutlet NSTextField* authorDateTextField;
@property(nonatomic, weak) IBOutlet NSTextField* committerTextField;
@property(nonatomic, weak) IBOutlet NSTextField* committerDateTextField;
@property(nonatomic, weak) IBOutlet NSView* contentsView;
@property(nonatomic, weak) IBOutlet NSView* filesView;
@property(nonatomic, weak) IBOutlet NSBox* separatorBox;
Expand Down Expand Up @@ -121,9 +122,10 @@ - (void)setCommit:(GCHistoryCommit*)commit {
CGFloat delta = ceil(size.height) - _messageTextField.frame.size.height;
_infoView.frame = NSMakeRect(0, 0, frame.size.width, frame.size.height + delta);

_sha1TextField.stringValue = _commit.shortSHA1;
_sha1TextField.stringValue = _commit.SHA1;

_dateTextField.stringValue = [NSString stringWithFormat:@"%@ (%@)", [_dateFormatter stringFromDate:_commit.date], GIFormatDateRelativelyFromNow(_commit.date, NO)];
_authorDateTextField.stringValue = [NSString stringWithFormat:@"%@ (%@)", [_dateFormatter stringFromDate:_commit.authorDate], GIFormatDateRelativelyFromNow(_commit.authorDate, NO)];
_committerDateTextField.stringValue = [NSString stringWithFormat:@"%@ (%@)", [_dateFormatter stringFromDate:_commit.committerDate], GIFormatDateRelativelyFromNow(_commit.committerDate, NO)];

CGFloat authorFontSize = _authorTextField.font.pointSize;
NSMutableAttributedString* author = [[NSMutableAttributedString alloc] init];
Expand Down Expand Up @@ -158,9 +160,10 @@ - (void)setCommit:(GCHistoryCommit*)commit {
[_diffFilesViewController setDeltas:_diff.deltas usingConflicts:nil];
} else {
_sha1TextField.stringValue = @"";
_dateTextField.stringValue = @"";
_authorTextField.stringValue = @"";
_authorDateTextField.stringValue = @"";
_committerTextField.stringValue = @"";
_committerDateTextField.stringValue = @"";
_messageTextField.stringValue = @"";

_diff = nil;
Expand Down
50 changes: 30 additions & 20 deletions GitUpKit/Views/en.lproj/GIQuickViewController.xib
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="8191"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="GIQuickViewController">
<connections>
<outlet property="authorDateTextField" destination="NMY-tY-Mrh" id="cJd-Hg-sbc"/>
<outlet property="authorTextField" destination="Men-K8-VwT" id="LJG-fX-aM1"/>
<outlet property="committerDateTextField" destination="p8J-vi-dDp" id="rnb-jG-CSk"/>
<outlet property="committerTextField" destination="5Yv-8b-x0c" id="RhJ-im-KYY"/>
<outlet property="contentsView" destination="gnd-mU-OFa" id="aua-gs-pD6"/>
<outlet property="dateTextField" destination="1k6-eF-els" id="BVt-4X-eK9"/>
<outlet property="filesView" destination="T7C-Lf-raW" id="mzB-kk-e11"/>
<outlet property="infoScrollView" destination="A0F-jI-s4n" id="bGh-0w-P8p"/>
<outlet property="infoView" destination="Bpc-ZA-3gm" id="hGF-hw-1ve"/>
Expand Down Expand Up @@ -49,33 +50,24 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view id="Bpc-ZA-3gm" customClass="GIFlippedView">
<rect key="frame" x="0.0" y="0.0" width="300" height="100"/>
<rect key="frame" x="0.0" y="0.0" width="300" height="130"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<customView id="aKy-Bi-5hY">
<rect key="frame" x="0.0" y="0.0" width="300" height="100"/>
<rect key="frame" x="0.0" y="0.0" width="300" height="130"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="9bU-TV-AfR">
<rect key="frame" x="8" y="80" width="60" height="14"/>
<rect key="frame" x="8" y="110" width="278" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;SHA1&gt;" id="Tsu-dV-mjp">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="1k6-eF-els">
<rect key="frame" x="72" y="80" width="218" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="right" title="&lt;DATE&gt;" id="iv2-j9-9i9">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.25" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" id="CIg-ZV-lYt">
<rect key="frame" x="8" y="54" width="282" height="14"/>
<rect key="frame" x="8" y="84" width="282" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<textFieldCell key="cell" controlSize="small" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;MESSAGE&gt;" id="fqu-LQ-wKF">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -84,33 +76,51 @@
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="LRK-cU-aip">
<rect key="frame" x="10" y="34" width="10" height="10"/>
<rect key="frame" x="10" y="57" width="10" height="10"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" image="icon_author" id="a14-H7-Quo"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Men-K8-VwT">
<rect key="frame" x="21" y="32" width="269" height="14"/>
<rect key="frame" x="21" y="55" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;AUTHOR&gt;" id="11W-Hl-yV0">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="NMY-tY-Mrh">
<rect key="frame" x="21" y="41" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;AUTHOR_DATE&gt;" id="ESf-oA-sr2">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" id="WZG-3V-AFB">
<rect key="frame" x="10" y="12" width="10" height="10"/>
<rect key="frame" x="10" y="21" width="10" height="10"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" image="icon_committer" id="BIg-uL-lng"/>
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="5Yv-8b-x0c">
<rect key="frame" x="21" y="10" width="269" height="14"/>
<rect key="frame" x="21" y="19" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;COMMITTER&gt;" id="4Tl-BB-pru">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="p8J-vi-dDp">
<rect key="frame" x="21" y="7" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;COMMITTER_DATE&gt;" id="Dbg-2h-APW">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</customView>
</subviews>
Expand Down

0 comments on commit 3a6edc0

Please sign in to comment.