Code Monkey home page Code Monkey logo

grit's Introduction

This is archived!

I brought out the code for grit explode as git split.

To open branches or issues, use git open.

Happy Gitting!

grit

grit: A rationalized git workflow.

(Beta 0.8)

This is a little command line tool to help programmers developing using GitHub and *nix. Grit automates many common command line tasks away and makes navigation a breeze.

How to install

  1. Download the code.
  2. Set an alias to grit/Grit.py.
  3. Set an environment variable in your .bashrc export GIT_USER=<your-username-on-github>

How to use

grit has the following commands: amend, branches, clone, cd, help, find, new, open, pulls, remake, remotes, and test.

From most interesting commands down, it's probably open, find, cd, new, clone, branches...

Each is documented below and through help.

There's also a file, https://github.com/rec/grit/blob/master/for-your-bashrc.sh, which has a list of shortcuts you might want to put in your .bashrc file.

Roots

Some grit commands are for programmers with multiple git directories active at one time. For example, the branches command prints out "all branches in all roots". What does this mean?

grit has the concept of your "Git root" - the base directory for the git repository that contains your current directory. If you aren't in a Git directory, the Git root is empty.

And there's also the "super root" - the directory above the Git root. If the Git root is empty, the container root is your current directory. So "all branches in all roots" means all git directories in your super root - which is probably "all sibling git directories" if you're in a Git directory.

Finally, some commands are considered "unsafe" and require yes/no confirmation before you use them.

amend

Amends the previous change, keeping the same change description and adding all git files that have been changed. Equivalent to git commit --amend --no-edit -a.

grit a[mend] [p[ush]]

With the optional push argument, also force-push the result, equivalent to git push -f.

Unsafe.

branches

grit b[ranches] [<prefix>]

Lists all git roots and their branches. If there is a prefix, only git roots that start with that prefix are listed.

The current branch in each repository is marked with a star (*).

A branch which has a current pull request out is marked with an exclamation mark (!).

cd commands

A set of commands to cycle through git roots.

Often passed to the shell's cd command like this:

 $ cd `grit +`

= grit + []

Prints the directory corresponding to this one in the next git root. If is non-empty, only cycles through directories starting with prefix.

= grit + [prefix]

Prints the directory corresponding to this one in the previous git root. If is non-empty, only cycles through directories starting with prefix.

^

grit ^

Prints the top-level directory in this git root.

clone

Clones the current project, sets up remote aliases, creates a new branch, builds and runs tests on the new repo.

grit c[lone] [<branch>] [<new repo name>]

If branch is empty, defaults to the base_branch (which is develop for rippled). If the new repo name is empty, selects a next incremental name from the directory name - e.g. rippled -> rippled2, rippled2 -> rippled3.

Unsafe

find

Finds files or directories by prefix and cycles through them.

grit f[ind] <prefix>

Finds the next directory that starts with , or the next directory that coontains a file that start with , and prints it.

Often used as an argument to the cd command, like this:

$ cd `grit f RippleCalc`

help

Prints help on grit.

grit h[elp]

Lists all commands.

git h[elp] [command]

Prints help on one command.

new

Creates a new source file in the git repository.

grit n[ew] <filename> [<filename> ...]

Creates a new source file with C++ guards, adds it to the git repo, remakes the project files.

Requires templates for each new filetype. The rippled project has templates for .cpp and .h.

open

Opens a file or directory in a github.com web page.

grit o[pen] [<filename or prefix>]

With no arguments, opens the current directory and branch within http://github.com in your browser.

With a filename or prefix, opens the first file or directory in the current directory which starts with that prefix.

pulls

Lists all the pull requests for the main project repo.

  grit p[ull]

remake

Remakes the makefile, sconsfile or other build file when files have been added or removed.

grit rema[ke]

Automatically called by grit new.

remotes

Add all the remotes git nicknames for your project.

grit remo[tes]

Automatically called by grit clone.

test

Run tests for the project.

grit t[est]

Automatically called by grit clone.

grit's People

Contributors

nbougalis avatar rec avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

nbougalis

grit's Issues

branch message is screwed up for repos in the middle of a rebase.

tom@builder:/development/rippled5$ gb
grit:         *master
rippled:      develop ripple-calc *ripple-lines vb x-ledger
rippled4:     *ripple-calc) develop ripple-calc
rippled5:     develop *ripd-427(476)
rippled6:     develop *rpc2
tom@builder:/development/rippled5$ -
tom@builder:/development/rippled4$ git branch
* (no branch, rebasing ripple-calc)
  develop
  ripple-calc
tom@builder:/development/rippled4$ 

Find and open feature list.

Results:

  • web page
    • three ways to open:
      • in this branch
      • in the upstream repo.
      • in someone else's repo
    • open a source file or directory.
    • open the root directory.
    • open the list of commits.
    • open the pull request for this branch.
    • open all pull requests for the upstream
  • cd to a directory
  • edit a file

You should be able to find the file in another directory.

Traceback in New command (relating to remake).

NodeCursor.cpp written and git added.
Traceback (most recent call last):
File "/development/grit/Grit.py", line 36, in
COMMANDS.run_safe((sys.argv[1:] or ['branches']))
File "/development/grit/grit/CommandList.py", line 63, in run_safe
cmd.function(_args)
File "/development/grit/grit/command/New.py", line 61, in new
Call.call(remake, cwd=root)
File "/development/grit/grit/Call.py", line 25, in call
returncode = subprocess.call(cmd, *_kwds)
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(_popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1198, in _execute_child
args = list(args)
TypeError: 'bool' object is not iterable

Clean up documentation.

  1. Make sure each individual command has correct dox.
  2. Top-level dox.
  3. Copy results to the README.md page.

clone continues to test even if it fails to build.

scons: building terminated because of errors.
ERROR: command = scons code = 2
Traceback (most recent call last):
File "grit/Grit.py", line 36, in
COMMANDS.run_safe((sys.argv[1:] or ['branches']))
File "/development/grit/grit/CommandList.py", line 63, in run_safe
cmd.function(_args)
File "/development/grit/grit/command/Clone.py", line 74, in clone
Test.run_test(directory)
File "/development/grit/grit/command/Test.py", line 19, in run_test
Call.for_each(test.format(project=Settings.PROJECT), cwd=cwd)
File "/development/grit/grit/Call.py", line 47, in for_each
if call(command, *_kwds):
File "/development/grit/grit/Call.py", line 25, in call
returncode = subprocess.call(cmd, *_kwds)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 524, in call
return Popen(_popenargs, *_kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 711, in init
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

grit new throws an exception

$ new NodeDirectory.h
Traceback (most recent call last):
  File "/development/grit/Grit.py", line 36, in <module>
    _COMMANDS.run_safe(*(sys.argv[1:] or ['branches']))
  File "/development/grit/grit/CommandList.py", line 63, in run_safe
    cmd.function(*args)
  File "/development/grit/grit/command/New.py", line 40, in new
    settings = Project.settings('new')
  File "/development/grit/grit/Project.py", line 17, in settings
    settings.update(File.get_json(ROOT, *names))
  File "/development/grit/grit/File.py", line 24, in get_json
    return json.load(open(root_relative(path)))
  File "/usr/lib/python2.7/json/__init__.py", line 290, in load
    **kw)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 3 column 1 (char 29)

.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.