summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst72
1 files changed, 72 insertions, 0 deletions
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..12ba356
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,72 @@
1src.sh
2======
3
4Simple shell function to clone and navigate git source respositories in a
5golang-style directory layout.
6
7golang dictates a strict directory layout and provides helper programs to
8fetch source code into the right structure. Other languages do not mandate such
9a layout, but neither do they have any problems if one is used. ``src.sh`` was
10written to facilitate managing all of ones source repos in the same structure,
11regardless of whether one is programming in go or not.
12
13Installation
14------------
15
16Either copy the contents of ``src.sh`` to your ``~/.bash_profile`` or
17copy the file into ``/etc/profile.d`` then re-login. It's also possible
18to ``source src.sh`` in the current shell if you don't want to re-login.
19
20A new shell function `src` will be available.
21
22Usage
23-----
24
25``src.sh`` either clones or changes directories to a given source repo
26location.
27
28.. code-block:: bash
29
30 src emonty/src.sh
31
32Results in the ``emonty/src.sh`` repo being cloned to
33``~/src/github.com/emonty/src.sh`` if it's not already there and that being set
34to the current directory.
35
36Configuration
37-------------
38
39``src.sh`` uses the golang source directory layout scheme, but uses
40``$SRCSRCDIR`` instead of ``$GOPATH`` as the primary variable. If ``$GOPATH``
41is set and ``$SRCSRCDIR`` is not set, ``$SRCSRCDIR`` defaults to
42``$GOPATH/src``. If neither are set, ``$SRCSRCDIR`` defaults to ``~/src``.
43
44``$SRCSRCDIR``, while ugly, was chosen because the function is called "src" but
45``$SRCDIR`` is much more likely to be already be used, possibly for some other
46purpose.
47
48``src.sh`` supports a configurable ordered list of prefixes to try, for folks
49who have frequent groups of things they work with. ``$SRCSRCPREFIXES``
50defaults to "github.com". For instance:
51
52.. code-block:: bash
53
54 export SRCSRCPREFIXES="git.openstack.org/openstack-infra \
55 git.openstack.org/openstack \
56 github.com"
57 src shade
58
59Results in shade being cloned to
60``~/src/git.openstack.org/openstack-infra/shade``.
61
62``src.sh`` defaults to using cd to change directories. Setting
63``$SRCSRCUSEPUSHD=1`` will cause it to use pushd instead.
64
65Use of go get by default
66------------------------
67
68By default, ``src.sh`` uses ``go get -d`` to do the cloning. If you do not have
69``go get`` in your path, it will use a less efficient set of shell commands
70and attempt cloning directly. ``go get`` has a better idea of whether or not
71you're requesting a full path to something or not, so it's recommended to just
72have it installed somewhere in your path.