Skip to content

command line completion for gitup command #1

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

Closed
wants to merge 3 commits into from
Closed

command line completion for gitup command #1

wants to merge 3 commits into from

Conversation

goranche
Copy link

added a simple command line completion script; added code to install.sh, which loads the command line completion script from /etc/bashrc

code to install.sh to load it from /etc/bashrc
@@ -0,0 +1,10 @@
#!/bin/sh -e
function _gitup() {
local cur opts
Copy link
Contributor

Choose a reason for hiding this comment

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

GitUp uses double-spaces instead of tabs everywhere

Copy link
Author

Choose a reason for hiding this comment

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

ugh, sorry... 😊
will fix

@swisspol
Copy link
Contributor

Thinking more about this, the general concern I have is that installing a symlink in /usr/bin is one thing, and easily revertable too, but patching /etc/bashrc is another. At the minimum the user should be prompted to allow this extra operation.

And then, there's this problem: http://apple.stackexchange.com/questions/193368/what-is-the-rootless-feature-in-el-capitan-really

@goranche
Copy link
Author

installing a symlink in /usr/bin is one thing, and easily revertable too, but patching /etc/bashrc is another

ok, not much I can do here 😃 I personally don't see it that way, I don't really have a problem with adding functionality, especially since there are no side effects even if GitUp is removed from the system.

it'd be better if bash on OS X was set up like on Ubuntu, but unfortunately it isn't 😒

regarding the RootLess feature in El Capitan, I don't really see an issue here, I don't see it changing anything that is being done here

@swisspol
Copy link
Contributor

Isn't /etc/bashrc not writable in El Capitan?

@goranche
Copy link
Author

Isn't /etc/bashrc not writable in El Capitan?

💭 AFAIK no... from the article you linked:

You can't modify anything in /System, /bin, /sbin, or /usr (except /usr/local).
...
But since normal OS X-style customizations go in /Library (or ~/Library, or /Applications), and unix-style customizations (e.g. Homebrew) go in /usr/local (or sometimes /etc), this shouldn't be a big deal.

as I understand it, nothing changes for "normal" locations, including /etc

I really hope I'm not wrong, because in that case a lot of my other scripts will break as well, including my Xcode server integrations 😟

@fnky
Copy link

fnky commented Aug 20, 2015

I don't like the approach of overwriting bashrc. Also this wouldn't work if the user uses a shell that does not run bashrc.

Plus there's a lot of developers who doesn't use the *rc file for scripts like these, but rather have modularized their dotfiles into plugins/topics and only use the *rc file as bootstrap.

@goranche
Copy link
Author

I don't like the approach of overwriting bashrc

ok, cool, just close the PR then 😒 👍

😉

@fnky
Copy link

fnky commented Aug 20, 2015

You're right, should have been less egoistic, but I meant “It's not a good idea to ...”

@goranche
Copy link
Author

don't worry about it, I meant my response as a silly one 😊 😉

I too would love it if Apple had configured bash to use /etc/bash_completion.d (like Debian), so we could just create a file named /etc/bash_completion.d/gitup and be done with it... but unfortunately, they didn't 😒 and as it is, I don't really see a better way of doing this on OS X

but of course, it's a small feature, doubt too many people would really even notice it 😇

@fnky
Copy link

fnky commented Aug 20, 2015

What could be done is having documentation, similar to Git to inform how users can install auto-completion, so it's more of an opt-in approach rather than forcing it on them.

@goranche
Copy link
Author

true, that would be an option as well...

💭 should the auto-complete script be left in the GitUp.app bundle, or move it out as well?

in that case we would instruct the user to source the script in the bundle, which would allow for upgrades should the gitup command gain options

@fnky
Copy link

fnky commented Aug 20, 2015

While it is easier to update the app from a developer point of view, what would happen if the app is deleted or moved from location, and possibly other reasons I can't think off my head at the moment.

@goranche
Copy link
Author

it just will not load (I like to use [ -f ... ] checks)

@fnky
Copy link

fnky commented Aug 20, 2015

Then it could a possible solution :-)

@swisspol
Copy link
Contributor

in that case we would instruct the user to source the script in the bundle, which would allow for upgrades should the gitup command gain options

Yes, that's already how it works for the tool: it's just symlink'ed, which guarantees it's always in sync with the app. Yes, it would break if people relocate the app after installing the tool, but that's not a problem in real-life.

@swisspol
Copy link
Contributor

Looks like there's no user friendly and reliable way to do this, so I'm going to close this. Thanks for taking a pass at it though! 😄

@swisspol swisspol closed this Aug 29, 2015
@lucasderraugh lucasderraugh mentioned this pull request Jul 2, 2019
1 task
gr00nd referenced this pull request in Gr00nd-INC/GitUp Sep 21, 2023
(https://travis-ci.org/git-up/GitUp.svg?branch=master)](https://travis-ci.org/git-up/GitUp)  GitUp =====  **Work quickly, safely, and without headaches. The Git interface you've been missing all your life has finally arrived.**  <p align="center"> <img src="https://i.imgur.com/JuQIxJu.png" width="50%" height="50%"><img src="https://i.imgur.com/9rgXktz.png" width="50%" height="50%"> </p>  Git recently celebrated its 10 years anniversary, but most engineers are still confused by its intricacy (3 of the [top 5 questions of all time](http://stackoverflow.com/questions?sort=votes) on Stack Overflow are Git related). Since Git turns even simple actions into mystifying commands (“git add” to stage versus “git reset HEAD” to unstage anyone?), it’s no surprise users waste time, get frustrated, distract the rest of their team for help, or worse, screw up their repo!  GitUp is a bet to invent a new Git interaction model that lets engineers of all levels work quickly, safely, and without headaches. It's unlike any other Git client out there from the way it’s built (it interacts directly with the Git database on disk), to the way it works (you manipulate the repository graph instead of manipulating commits).  With GitUp, you get a truly efficient Git client for Mac: - A **live and interactive repo graph** (edit, reorder, fixup, merge commits…), - **Unlimited undo / redo** of almost all operations (even rebases and merges), - Time Machine like **snapshots for 1-click rollbacks** to previous repo states, - Features that don’t even exist natively in Git like a **visual commit splitter** or a **unified reflog browser**, - **Instant search across the entire repo** including diff contents,  - A **ridiculously fast UI**, often faster than the command line.  *GitUp was created by [@swisspol](https://github.com/swisspol) in late 2014 as a bet to reinvent the way developers interact with Git. After several months of work, it was made available in pre-release early 2015 and reached the [top of Hacker News](https://news.ycombinator.com/item?id=9653978) along with being [featured by Product Hunt](http://www.producthunt.com/tech/gitup-1) and [Daring Fireball](http://daringfireball.net/linked/2015/06/04/gitup). 30,000 lines of code later, GitUp reached 1.0 mid-August 2015 and was released open source as a gift to the developer community.*  Getting Started ===============  - Official website: https://gitup.co  ## Download:  - Latest release on GitHub: https://github.com/git-up/GitUp/releases - Homebrew (Not maintained by GitUp developers): `brew install homebrew/cask/gitup` (Note: There is already a formula called gitup, so the full name must be specified!)  **Read the [docs](https://github.com/git-up/GitUp/wiki) and use [GitHub Issues](https://github.com/git-up/GitUp/issues) for support & feedback.**  Releases notes are available at https://github.com/git-up/GitUp/releases. Builds tagged with a `v` (e.g. `v1.2.3`) are released on the "Stable" channel, while builds tagged with a `b` (e.g. `b1234`) are only released on the "Continuous" channel. You can change the update channel used by GitUp in the app preferences.  ## Build  To build GitUp yourself, simply run the command `git clone --recursive https://github.com/git-up/GitUp.git` in Terminal, then open the `GitUp/GitUp.xcodeproj` Xcode project and hit Run.  **IMPORTANT:** If you do not have an Apple ID with a developer account for code signing Mac apps, the build  will fail with a code signing error. Simply delete the "Code Signing Identity" build setting of the "Application" target to work around the issue:  <p align="center"> <img src="http://i.imgur.com/dWpJExk.png"> </p>  **Alternatively**, if you do have a developer account, you can create the file "Xcode-Configurations/DEVELOPMENT_TEAM.xcconfig" with the following build setting as its content: > DEVELOPMENT_TEAM = [Your TeamID]  For a more detailed description of this, you can have a look at the comments at the end of the file "Xcode-Configurations/Base.xcconfig".   GitUpKit ========  **GitUp is built as a thin layer on top of a reusable generic Git toolkit called "GitUpKit". This means that you can use that same GitUpKit framework to build your very own Git UI!**  *GitUpKit has a very different goal than [ObjectiveGit](https://github.com/libgit2/objective-git). Instead of offering extensive raw bindings to [libgit2](https://github.com/libgit2/libgit2), GitUpKit only uses a minimal subset of libgit2 and reimplements everything else on top of it (it has its own "rebase engine" for instance). This allows it to expose a very tight and consistent API, that completely follows Obj-C conventions and hides away the libgit2 complexity and sometimes inconsistencies. GitUpKit adds on top of that a number of exclusive and powerful features, from undo/redo and Time Machine like snapshots, to entire drop-in UI components.*  Architecture ------------  The GitUpKit source code is organized as 2 independent layers communicating only through the use of public APIs:  **Base Layer (depends on Foundation only and is compatible with OS X and iOS)** - `Core/`: wrapper around the required minimal functionality of [libgit2](https://github.com/libgit2/libgit2), on top of which is then implemented all the Git functionality required by GitUp (note that GitUp uses a [slightly customized fork](https://github.com/git-up/libgit2/tree/gitup) of libgit2) - `Extensions/`: categories on the `Core` classes to add convenience features implemented only using the public APIs  **UI Layer (depends on AppKit and is compatible with OS X only)** - `Interface/`: low-level view classes e.g. `GIGraphView` to render the GitUp Map view - `Utilities/`: interface utility classes e.g. the base view controller class `GIViewController` - `Components/`: reusable single-view view controllers e.g. `GIDiffContentsViewController` to render a diff - `Views/`: high-level reusable multi-views view controllers e.g. `GIAdvancedCommitViewController` to implement the entire GitUp Advanced Commit view  **IMPORTANT**: If the preprocessor constant `DEBUG` is defined to a non-zero value when building GitUpKit (this is the default when building in "Debug" configuration), a number of extra consistency checks are enabled at run time as well as extra logging. Be aware that this overhead can significantly affect performance.  GitUpKit API ------------  Using the GitUpKit API should be pretty straightforward since it is organized by functionality (e.g. repository, branches, commits, interface components, etc...) and a best effort has been made to name functions clearly.  Regarding the "Core" APIs, the best way to learn them is to peruse the associated unit tests - for instance see [the branch tests](GitUpKit/Core/GCBranch-Tests.m) for the branch API.  Here is some sample code to get you started (error handling is left as an exercise to the reader):  **Opening and browsing a repository:** ```objc // Open repo GCRepository* repo = [[GCRepository alloc] initWithExistingLocalRepository:<PATH> error:NULL];  // Make sure repo is clean assert([repo checkClean:kGCCleanCheckOption_IgnoreUntrackedFiles error:NULL]);  // List all branches NSArray* branches = [repo listAllBranches:NULL]; NSLog(@"%@", branches);  // Lookup HEAD GCLocalBranch* headBranch;  // This would be nil if the HEAD is detached GCCommit* headCommit; [repo lookupHEADCurrentCommit:&headCommit branch:&headBranch error:NULL]; NSLog(@"%@ = %@", headBranch, headCommit);  // Load the *entire* repo history in memory for fast access, including all commits, branches and tags GCHistory* history = [repo loadHistoryUsingSorting:kGCHistorySorting_ReverseChronological error:NULL]; assert(history); NSLog(@"%lu commits total", history.allCommits.count); NSLog(@"%@\n%@", history.rootCommits, history.leafCommits); ```  **Modifying a repository:** ```objc // Take a snapshot of the repo GCSnapshot* snapshot = [repo takeSnapshot:NULL];  // Create a new branch and check it out GCLocalBranch* newBranch = [repo createLocalBranchFromCommit:headCommit withName:@"temp" force:NO error:NULL]; NSLog(@"%@", newBranch); assert([repo checkoutLocalBranch:newBranch options:0 error:NULL]);  // Add a file to the index [[NSData data] writeToFile:[repo.workingDirectoryPath stringByAppendingPathComponent:@"empty.data"] atomically:YES]; assert([repo addFileToIndex:@"empty.data" error:NULL]);  // Check index status GCDiff* diff = [repo diffRepositoryIndexWithHEAD:nil options:0 maxInterHunkLines:0 maxContextLines:0 error:NULL]; assert(diff.deltas.count == 1); NSLog(@"%@", diff);  // Create a commit GCCommit* newCommit = [repo createCommitFromHEADWithMessage:@"Added file" error:NULL]; assert(newCommit); NSLog(@"%@", newCommit);  // Restore repo to saved snapshot before topic branch and commit were created BOOL success = [repo restoreSnapshot:snapshot withOptions:kGCSnapshotOption_IncludeAll reflogMessage:@"Rolled back" didUpdateReferences:NULL error:NULL]; assert(success);    // Make sure topic branch is gone assert([repo findLocalBranchWithName:@"temp" error:NULL] == nil);    // Update workdir and index to match HEAD assert([repo resetToHEAD:kGCResetMode_Hard error:NULL]); ```  Complete Example #1: GitDown ----------------------------  [GitDown](Examples/GitDown) is a very basic app that prompts the user for a repo and displays an interactive and live-updating list of its stashes (all with ~20 lines of code in `-[AppDelegate applicationDidFinishLaunching:]`):  <p align="center"> <img src="http://i.imgur.com/ZfxM7su.png"> </p>  Through GitUpKit, this basic app also gets for free unlimited undo/redo, unified and side-by-side diffs, text selection and copy, keyboard shortcuts, etc...  This source code also demonstrates how to use some other GitUpKit view controllers as well as building a customized one.  Complete Example git-up#2: GitDiff ----------------------------  [GitDiff](Examples/GitDiff) demonstrates how to create a view controller that displays a live updating diff between `HEAD` and the workdir à la `git diff HEAD`:  <p align="center"> <img src="http://i.imgur.com/29hxDcJ.png"> </p>  Complete Example git-up#3: GitY -------------------------  [GitY](Examples/GitY) is a [GitX](http://gitx.frim.nl/) clone built using GitUpKit and less than 200 lines of code:  <p align="center"> <img src="http://i.imgur.com/6cuPcT4.png"> </p>  Complete Example git-up#4: iGit -------------------------  [iGit](Examples/iGit) is a test iOS app that simply uses GitUpKit to clone a GitHub repo and perform a commit.  Contributing ============  See [CONTRIBUTING.md](CONTRIBUTING.md).  Credits =======  - [@swisspol](https://github.com/swisspol): concept and code - [@wwayneee](https://github.com/wwayneee): UI design - [@jayeb](https://github.com/jayeb): website  *Also a big thanks to the fine [libgit2](https://libgit2.github.com/) contributors without whom GitUp would have never existed!*  License =======  GitUp is copyright 2015-2018 Pierre-Olivier Latour and available under [GPL v3 license](http://www.gnu.org/licenses/gpl-3.0.txt). See the [LICENSE](LICENSE) file in the project for more information.  **IMPORTANT:** GitUp includes some other open-source projects and such projects remain under their own license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants