Skip to content

Feature. Advanced Commit View: Filter files text field. #669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 91 additions & 50 deletions GitUp/Application/Base.lproj/PreferencesWindowController.xib

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions GitUpKit/Core/GCLiveRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ extern NSString* const GCLiveRepositoryAmendOperationReason;
@property(nonatomic, readonly) GCDiff* workingDirectoryStatus; // Nil on error
@property(nonatomic, readonly) GCDiff* indexStatus; // Nil on error
@property(nonatomic, readonly) NSDictionary* indexConflicts; // Nil on error
@property(nonatomic, copy) NSString *filePattern;
- (void)updateFilePattern:(NSString *)filePattern;

@property(nonatomic, getter=areStashesEnabled) BOOL stashesEnabled; // Default is NO - Should be enabled *after* setting delegate so any error can be received
@property(nonatomic, readonly) NSArray* stashes; // Nil on error
Expand Down
15 changes: 12 additions & 3 deletions GitUpKit/Core/GCLiveRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ - (void)_updateStatus:(BOOL)notify {

CFAbsoluteTime time = CFAbsoluteTimeGetCurrent();
if (_statusMode == kGCLiveRepositoryStatusMode_Unified) {
unifiedDiff = [self diffWorkingDirectoryWithHEAD:nil
unifiedDiff = [self diffWorkingDirectoryWithHEAD:self.filePattern
options:(self.diffBaseOptions | kGCDiffOption_IncludeUntracked | kGCDiffOption_FindRenames)
maxInterHunkLines:_diffMaxInterHunkLines
maxContextLines:_diffMaxContextLines
Expand All @@ -639,13 +639,13 @@ - (void)_updateStatus:(BOOL)notify {
}
} else {
XLOG_DEBUG_CHECK(_statusMode == kGCLiveRepositoryStatusMode_Normal);
indexDiff = [self diffRepositoryIndexWithHEAD:nil
indexDiff = [self diffRepositoryIndexWithHEAD:self.filePattern
options:(self.diffBaseOptions | kGCDiffOption_FindRenames)
maxInterHunkLines:_diffMaxInterHunkLines
maxContextLines:_diffMaxContextLines
error:&error];
if (indexDiff) {
workdirDiff = [self diffWorkingDirectoryWithRepositoryIndex:nil
workdirDiff = [self diffWorkingDirectoryWithRepositoryIndex:self.filePattern
options:(self.diffBaseOptions | kGCDiffOption_IncludeUntracked)
maxInterHunkLines:_diffMaxInterHunkLines
maxContextLines:_diffMaxContextLines
Expand Down Expand Up @@ -725,6 +725,15 @@ - (void)_updateStashes:(BOOL)notify {
}
}

#pragma mark - FilePattern
- (void)updateFilePattern:(NSString *)filePattern {
if ([self.filePattern isEqualToString:filePattern]) {
return;
}
self.filePattern = filePattern == nil ? nil : [NSString stringWithFormat:@"*%@*", filePattern];
[self _updateStatus:YES];
}

#pragma mark - Operations

- (void)setUndoManager:(NSUndoManager*)undoManager {
Expand Down
16 changes: 16 additions & 0 deletions GitUpKit/Extensions/NSView+Embedding.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// NSView+Embedding.h
// GitUpKit (OSX)
//
// Created by Dmitry Lobanov on 06.04.2020.
//

#import <AppKit/AppKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface NSView (Embedding)
- (void)embedView:(NSView *)view;
@end

NS_ASSUME_NONNULL_END
37 changes: 37 additions & 0 deletions GitUpKit/Extensions/NSView+Embedding.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// NSView+Embedding.m
// GitUpKit (OSX)
//
// Created by Dmitry Lobanov on 06.04.2020.
//

#import "NSView+Embedding.h"

@implementation NSView (Embedding)
- (void)embedView:(NSView *)view {
[self.class embedView:view inView:self];
}

+ (void)embedView:(NSView *)view inView:(NSView *)superview {
[superview addSubview:view];
view.translatesAutoresizingMaskIntoConstraints = NO;

if (superview != nil && view != nil) {
if (@available(macOS 10.11, *)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: @lolgear think about deprecate low mac versions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NikKovIos I’ll take a pass at cleaning this up on a new branch. The original author did enough on this one for me to push it over the finish line.

NSArray *constraints = @[
[view.leftAnchor constraintEqualToAnchor:superview.leftAnchor],
[view.topAnchor constraintEqualToAnchor:superview.topAnchor],
[view.bottomAnchor constraintEqualToAnchor:superview.bottomAnchor],
[view.rightAnchor constraintEqualToAnchor:superview.rightAnchor]
];
[NSLayoutConstraint activateConstraints:constraints];
} else {
// Fallback on earlier versions
NSArray *verticalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:@{@"view": view}];
NSArray *horizontalConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|" options:0 metrics:nil views:@{@"view": view}];
NSArray *constraints = [[NSArray arrayWithArray:verticalConstraints] arrayByAddingObjectsFromArray:horizontalConstraints];
[NSLayoutConstraint activateConstraints:constraints];
}
}
}
@end
8 changes: 8 additions & 0 deletions GitUpKit/GitUpKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
0A5BF6A62578EFB300B98F4F /* NSView+Embedding.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A5BF6A42578EFB200B98F4F /* NSView+Embedding.h */; };
0A5BF6A72578EFB300B98F4F /* NSView+Embedding.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A5BF6A52578EFB300B98F4F /* NSView+Embedding.m */; };
0AC8525923A122C400479160 /* GILaunchServicesLocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0AC8525723A122C400479160 /* GILaunchServicesLocator.h */; settings = {ATTRIBUTES = (Public, ); }; };
0AC8525A23A122C400479160 /* GILaunchServicesLocator.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AC8525823A122C400479160 /* GILaunchServicesLocator.m */; };
1DF371CD22F5262300EF7BD9 /* GCLiveRepository+Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1DF371CB22F5262300EF7BD9 /* GCLiveRepository+Utilities.h */; };
Expand Down Expand Up @@ -427,6 +429,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
0A5BF6A42578EFB200B98F4F /* NSView+Embedding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSView+Embedding.h"; sourceTree = "<group>"; };
0A5BF6A52578EFB300B98F4F /* NSView+Embedding.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSView+Embedding.m"; sourceTree = "<group>"; };
0AC8525723A122C400479160 /* GILaunchServicesLocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GILaunchServicesLocator.h; sourceTree = "<group>"; };
0AC8525823A122C400479160 /* GILaunchServicesLocator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GILaunchServicesLocator.m; sourceTree = "<group>"; };
1DF371CB22F5262300EF7BD9 /* GCLiveRepository+Utilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "GCLiveRepository+Utilities.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -870,6 +874,8 @@
E2735B2119FF763300ED0CC4 /* Extensions */ = {
isa = PBXGroup;
children = (
0A5BF6A42578EFB200B98F4F /* NSView+Embedding.h */,
0A5BF6A52578EFB300B98F4F /* NSView+Embedding.m */,
E259C2D41A64FAA40079616B /* GCHistory+Rewrite-Tests.m */,
E2D414891A02D68700B99634 /* GCHistory+Rewrite.h */,
E2D4148A1A02D68700B99634 /* GCHistory+Rewrite.m */,
Expand Down Expand Up @@ -1187,6 +1193,7 @@
E267E2281B84DBE700BAB377 /* GIWindowController.h in Headers */,
E267E2361B84DC3900BAB377 /* GICommitListViewController.h in Headers */,
E267E2371B84DC3900BAB377 /* GIDiffContentsViewController.h in Headers */,
0A5BF6A62578EFB300B98F4F /* NSView+Embedding.h in Headers */,
E267E2381B84DC3900BAB377 /* GIDiffFilesViewController.h in Headers */,
E267E2391B84DC3900BAB377 /* GISnapshotListViewController.h in Headers */,
1DF371CD22F5262300EF7BD9 /* GCLiveRepository+Utilities.h in Headers */,
Expand Down Expand Up @@ -1470,6 +1477,7 @@
E267E1D11B84D83100BAB377 /* GCBranch.m in Sources */,
E267E1D21B84D83100BAB377 /* GCCommit.m in Sources */,
E267E1D31B84D83100BAB377 /* GCCommitDatabase.m in Sources */,
0A5BF6A72578EFB300B98F4F /* NSView+Embedding.m in Sources */,
E267E1D41B84D83100BAB377 /* GCDiff.m in Sources */,
E267E1D51B84D83100BAB377 /* GCFoundation.m in Sources */,
E267E1D61B84D83100BAB377 /* GCFunctions.m in Sources */,
Expand Down
Loading