sagemath / git-trac-command

A "git trac" subcommand for git
GNU General Public License v3.0
13 stars 16 forks source link

Git-Trac Integration

About

This module implements a "git trac" subcommand of the git suite that interfaces with trac over XMLRPC.

Included is a one-page git cheat sheet for Sage/Git/Trac: http://github.com/sagemath/git-trac-command/raw/master/doc/git-cheat-sheet.pdf

Installation

The easiest way to just try out the code in this repo is to source the enable.sh script, which will prepend it to your PATH. This enables the git trac subcommand until you close that shell, so no permanent change is made:

$ git clone https://github.com/sagemath/git-trac-command.git
$ source git-trac-command/enable.sh
Prepending the git-trac command to your search PATH

Note for zsh users: enable.sh requires bash. Use one of the other options described below.

To permanently install the code from this repo, clone it and run setup.py:

$ git clone https://github.com/sagemath/git-trac-command.git
$ cd git-trac-command
$ python setup.py install --user

Alternatively you can just symlink git-trac to anywhere in your path:

$ git clone https://github.com/sagemath/git-trac-command.git
$ cd git-trac-command
$ ln -s `pwd`/git-trac ~/bin/

On a Mac, which may not have a default in the home directory for commands, it may be easier to add this to your .profile:

$ git clone https://github.com/sagemath/git-trac-command.git
$ cd git-trac-command
$ pico/vim/emacs $HOME/.profile
<add a line like "export PATH=$PATH:$HOME/Downloads/git-trac-command/bin">

Usage

Too Long, Didn't Read

To fix a bug, start with

$ git trac create "Fix foo"

This will open the ticket and create a new local branch t/<number>/fix_foo. Then edit Sage, followed by

$ git add <filename>
$ git commit

Repeat edit/commit as necessary. When you are finished, run

$ git trac push

It will take the ticket number out of the branch name, so you don't have to specify it.

Configuration

The scripts assume that the trac remote repository is set up as the remote trac in the local repo. That is, you should have the following for the Sage git server:

$ git remote add trac https://trac.sagemath.org/sage.git      # read-only
$ git remote add trac ssh://git@trac.sagemath.org/sage.git   # read-write
$ git remote -v
trac    ssh://git@trac.sagemath.org/sage.git (fetch)
trac    ssh://git@trac.sagemath.org/sage.git (push)

Trac username and password are stored in the local repo (the DOT_GIT/config file):

$ git trac config --user=Myself --pass=s3kr1t
Trac xmlrpc URL:
    https://trac.sagemath.org/xmlrpc (anonymous)
    https://trac.sagemath.org/login/xmlrpc (authenticated)
Username: Myself
Password: ******

Instead of a username and password you may also configure authentication via a generated token by passing --token=<token> instead of --pass:

$ git trac config --user=<username> --token=<token>

This is required if you authenticate to Trac with your GitHub account, as you do not have a Trac password.. Logged in users can find their token under https://trac.sagemath.org/prefs/token . Technically, token authentication does not require configuring a username. However, explicitly providing your username to the configuration is still required for many features to work correctly. If you log into Trac via GitHub, make sure this is your full username, including the gh- prefix.

If both a token and a username/password are configured, the token-based authentication takes precedence.

If you do not want to store your trac username/password/token on disk you can temporarily override it with the environment variables TRAC_USERNAME, TRAC_PASSWORD, and TRAC_TOKEN respectively. These take precedence over any other configuration.

Sage-Trac Specifics

Some of the functionality depends on the special trac plugins (see https://github.com/sagemath/sage_trac), namely:

Release Management

The Sage release management scripts are in the git-trac.releasemgr subdirectory. They are probably only useful to the Sage release manager.

Testing and Python Compatibility