-
Notifications
You must be signed in to change notification settings - Fork 78
Stage menu #30
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
Stage menu #30
Conversation
5a3ff52
to
9e38c57
Compare
if (!(userName && userEmail)) { | ||
return [[repository windowController] | ||
showMessageSheet:NSLocalizedString(@"User‘s name not set", | ||
@"Title for sheet that the user’s name is not set in the git configuration") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken indentation here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tiennou – looks OK on my machine, I suspect a tabs vs spaces issue here.
As far as I can tell, the project uses both of those indentation styles, so it’s hard to tell what’s right and what is wrong.
My Xcode seems to default on using tabs on the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI you can see the diff ignoring whitespace by appending ?w=1
to the diff url:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the tabstop width can be set with ?ts=4.
Xcode almost does the nice method of tabs for indentation, spaces for alignment. Instead it does tabs for indentation, both tabs and spaces for alignment...
(vim with list
/listchars
)
showMessageSheet:NSLocalizedString(@"User‘s name not set", | ||
@"Title for sheet that the user’s name is not set in the git configuration") | ||
infoText:NSLocalizedString(@"Signing off a commit requires setting user.name and user.email in your git config", | ||
@"Information text for sheet that the user’s name is not set in the git configuration")]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: indent
} | ||
|
||
NSString *SOBline = [NSString stringWithFormat:NSLocalizedString(@"Signed-off-by: %@ <%@>", | ||
@"Signed off message format. Most likely this should not be localised."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: indent
return; | ||
} | ||
|
||
if ([[cachedFilesController arrangedObjects] count] == 0) { | ||
[[repository windowController] showMessageSheet:@"No changes to commit" infoText:@"You must first stage some changes before committing"]; | ||
[repository.windowController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch. Maybe use local NSStrings so it's clearer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving that a shot – although I’m not entirely convinced that it really improves things (basically trading long lines against additional lines).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjacent string literals get concatenated, if that helps:
NSLocalizedString(@"You need to stage some changed files before committing "
"by moving them to the list of Staged Changes.",
@"Information text for sheet that you need to "
"stage changes before creating a commit")
The @ is optional on subsequent NSString literals.
if ([commitMessage length] < 3) { | ||
[[repository windowController] showMessageSheet:@"Commit message missing" infoText:@"Please enter a commit message before committing"]; | ||
if (commitMessage.length < kMinimalCommitMessageLength) { | ||
[repository.windowController |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here
NSString *reason = notification.userInfo[kNotificationDictionaryDescriptionKey]; | ||
self.status = [NSString stringWithFormat: | ||
NSLocalizedString(@"Commit failed: %@", | ||
@"Message in status bar when creating a commit has failed, including the reason for the failure"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick indent
Classes/git/PBGitIndex.m
Outdated
@@ -44,6 +44,7 @@ - (NSArray *)linesFromData:(NSData *)data; | |||
@interface PBGitIndex () { | |||
dispatch_queue_t _indexRefreshQueue; | |||
dispatch_group_t _indexRefreshGroup; | |||
BOOL amend; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the property, but name the ivar _amend
. That'll be less surprising (properties by default use a underscored ivar if there's one).
English.lproj/MainMenu.xib
Outdated
</connections> | ||
</menuItem> | ||
<menuItem isSeparatorItem="YES" id="DoS-f9-CnX"/> | ||
<menuItem title="Open in Terminal" keyEquivalent="T" id="942"> | ||
<menuItem title="Amend Commits" keyEquivalent="a" id="W5p-JV-xeS"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Amend Commit"
} | ||
|
||
|
||
- (PBGitIndex *) index { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you're keeping it around ? I think it could go away...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used from PBGitIndexController and PBWebChangesController, so those would need reworking to not repeat that chain of accessors over and over.
I didn’t want to get into that now, because it’s not really clear to me what the relations between those controllers and the objects they manipulate should be.
@@ -590,19 +590,20 @@ - (void)showCommitsFromTree:(id)sender | |||
- (void) checkoutFiles:(id)sender | |||
{ | |||
NSMutableArray *files = [NSMutableArray array]; | |||
for (NSString *filePath in [sender representedObject]) | |||
for (NSString *filePath in [sender representedObject]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
churn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you want a line break there
If we want to go down such a road, we should probably write down on the desired locations for spaces first and try to get the code into that shape. Is that worth the effort?
Would using clang-format in some way be helpful with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it was late, and the churn was getting hard to process.
I know the current style is messy (is there any code which isn't), I don't have an opinion on what to do about that yet. It's just distracting to read unrelated whitespace-bracing changes while you look at +667/-447 lines.
👍 for clang-format. If you have the will to make it work 😉. I'm mostly in-line with the GitHub Objective-C Style Guide.
@@ -177,7 +175,7 @@ - (void) commitWithVerification:(BOOL) doVerify | |||
|
|||
NSString *commitMessage = [commitMessageView string]; | |||
if ([commitMessage length] < 3) { | |||
[[repository windowController] showMessageSheet:@"Commitmessage missing" infoText:@"Please enter a commit message before committing"]; | |||
[[repository windowController] showMessageSheet:@"Commit message missing" infoText:@"Please enter a commit message before committing"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
churn
@@ -17,10 +17,6 @@ | |||
@class PBCommitMessageView; | |||
|
|||
@interface PBGitCommitController : PBViewController { | |||
// This might have to transfer over to the PBGitRepository | |||
// object sometime | |||
PBGitIndex *index; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
churn: can you split that change ?
@@ -41,7 +41,7 @@ - (void)closeView | |||
|
|||
- (void) didLoad | |||
{ | |||
[[self script] setValue:controller.index forKey:@"Index"]; | |||
[[self script] setValue:controller.index forKey:@"Index"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
churn
@interface PBOpenFiles : NSObject | ||
|
||
+ (void)showInFinderAction:(id)sender with:(NSURL *)workingDirectoryURL; | ||
+ (void)openFilesAction:(id)sender with:(NSURL *)workingDirectoryURL; | ||
+ (void)openFiles:(NSArray<PBChangedFile *> *)selectedFiles with:(NSURL *)workingDirectoryURL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That code is supposed to work with NSString
or PBChangedFile
and whatever you can throw at it (hence -selectedURLsFromSender:...`, so I'd prefer to keep it that way 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My line of thinking was the other way round … a) the code does only work for PBChangedFiles and b) it looks like a Utility to handle opening files.
I can see how it makes sense to add the ability to open other objects here when it’s needed. However, seeing this as a utility for opening files, I don‘t think it should receive UI-Elements as an input and expect them to represent specific objects. My idea was to extract the data from the UI at the controller layer and let this class handle opening the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That code was originally in PBGitRepositoryDocument
, where the responder chain would get to it in some way. And some things can throw paths at it (like, right-click-opening a changed file in the history view commit pane), which is why I wrote it that way. Now that we have submodules, we have that (generic) method, the stuff you've added for submodules, and a bug because right-click-open in the history view doesn't do the same thing...
@@ -15,11 +15,11 @@ @implementation PBFileChangesTableView | |||
|
|||
- (NSMenu *)menuForEvent:(NSEvent *)theEvent | |||
{ | |||
if ([self delegate]) { | |||
if(self.indexController) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent: missing space after if-statement. Also, I'd consider that churn 😉.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe redeclare -(id)delegate
as -(PBGitIndexController *)delegate
in the header if that's what you're after ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice idea!
… turns out that alone is not sufficient, I seem to need an implementation to match the header as well.
ignoreItem.target = self; | ||
[menu addItem:ignoreItem]; | ||
} | ||
+ (NSString *) getNameOfFirstFile:(NSArray<PBChangedFile *> *) selectedFiles { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move those class methods in PBTableViewWhatWasItsName
instead of keeping them here ?
I'm starting to love that view hierarchy 😉. Normally you could move the gist of |
This should also include the solution suggested in rowanj#24. Moves all menu activation/hiding to the validation method, so it can be used from the main menu as well as the contextual menu.
They are available in the main menu now.
I'm sorry, I'm NAK-ing that. I can't get myself to accept the weirdness that's going on in On the other hand, I tried it for a few days, and it seemed to work quite well (that menu is nice !), but as I have stuff cooking w.r.t to clarifying the view hierarchy which this PR step all over, let's do this : I'll propose the changes I want to make, then the massive redo-rebase of this one that will result is on me. Does that sound fair ? I really want to cleanup some of that stuff before the PR starting coming in 😓 |
@tiennou no problem, that’ll work for me. Just let me know what else you need me to do. |
As discussed in #24 and #25, this commit creates a »Stage« menu sets up the contextual menu in the xib file instead of in code and makes the action handling of the contextual menu reusable for the main menu bar.
As the general structure of the involved views/controllers still seems to be a little confusing to me, feel free to advise me of how to improve this (unless doing so would involve refactoring the whole thing ;).