Skip to content

Commit

Permalink
Merge pull request #157 from jacebrowning/release/v1.4
Browse files Browse the repository at this point in the history
Release v1.4
  • Loading branch information
jacebrowning authored Mar 21, 2017
2 parents c450028 + a8ecea7 commit cbeb731
Show file tree
Hide file tree
Showing 21 changed files with 135 additions and 116 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Revision History

## 1.4 (2017/03/21)

- Allow config files to exist in subdirectories of the main project.
- Added `${GITMAN_CACHE}` to customize the repository cache location.

## 1.3 (2017/02/03)

- Added `init` command to generate sample configuration files.
- Added `init` command to generate sample config files.
- Added support for post-install scripts on dependencies.
- Updated configuration format to support `null` for links.
- Updated config format to support `null` for links.

## 1.2 (2017/01/08)

Expand Down Expand Up @@ -39,7 +44,7 @@

## 0.9 (2016/03/31)

- Added `edit` command to launch the configuration file.
- Added `edit` command to launch the config file.
- Depth now defaults to 5 to prevent infinite recursion.
- Fixed handling of source lists containing different dependencies.

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ $ python setup.py install

## Setup

Generate a sample configuration file:
Generate a sample config file:

```sh
$ gitman init
Expand Down Expand Up @@ -83,7 +83,7 @@ which will essentially:
1. Create a working tree at `<root>`/`<location>`/`<name>`
2. Fetch from `repo` and checkout the specified `rev`
3. Symbolically link each `<location>`/`<name>` from `<root>`/`<link>` (if specified)
4. Repeat for all nested working trees containing a configuration file
4. Repeat for all nested working trees containing a config file
5. Record the actual commit SHAs that were checked out (with `--lock` option)
6. Run optional post-install scripts for each dependency

Expand Down
2 changes: 1 addition & 1 deletion docs/interfaces/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All of the [command-line interface](cli.md) functionality is available from the

## Init

To generate a sample configuration for a new project, call:
To generate a sample config for a new project, call:

```python
gitman.init()
Expand Down
8 changes: 4 additions & 4 deletions docs/interfaces/cli.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Command-line Interface

After setting up `gitman` with a [configuration file](../index.md#setup), various commands can be run to manage these Git-controlled source dependencies.
After setting up `gitman` with a [config file](../index.md#setup), various commands can be run to manage these Git-controlled source dependencies.

## Init

To generate a sample configuration for a new project, run:
To generate a sample config for a new project, run:

```sh
$ gitman init
Expand Down Expand Up @@ -150,7 +150,7 @@ To display the path to a dependency:
gitman show <name>
```

To display the path to the configuration file:
To display the path to the config file:

```sh
gitman show --config
Expand All @@ -164,7 +164,7 @@ gitman show --log

## Edit

To open the existing configuration file:
To open the existing config file:

```sh
gitman edit
Expand Down
11 changes: 11 additions & 0 deletions docs/setup/environment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Environment Setup

The following environment variables can be used to configure the behavior of GitMan.

## `GITMAN_CACHE`

GitMan utilizes local repository mirrors to cache dependencies and speed up cloning.
This variable specifies the path of a directory to store these repository references.
The default value should be overridden if `$HOME` is not set on your target system.

**Default**: `~/.gitcache`
2 changes: 1 addition & 1 deletion docs/use-cases/branch-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ tests

## Understanding Locked Sources

In the configuration file, the `sources_locked` section identifies that commit `b27308` of the API was last used to test this web app -- the last time `$ gitman update` was run.
In the config file, the `sources_locked` section identifies that commit `b27308` of the API was last used to test this web app -- the last time `$ gitman update` was run.

The `sources` section identifies that the `develop` branch should be used when checking out a new version of the API.

Expand Down
8 changes: 4 additions & 4 deletions docs/use-cases/build-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ clean:
gitman uninstall
```

using a configuration file similar to:
using a config file similar to:

```yaml
location: vendor/gitman
Expand All @@ -47,8 +47,8 @@ sources_locked:
Running `make depends` performs the following actions:

1. Check the modification times of the configuration and log files
2. If the configuration file is newer, continue
1. Check the modification times of the config and log files
2. If the config file is newer, continue
3. Install the locked dependency versions
4. Run `make` inside of each dependency's folder
5. Update the log file with the current versions of all dependencies
Expand All @@ -57,4 +57,4 @@ To update your dependencies:

1. Run `gitman update`
2. Run `make depends`
3. If the new build passes your tests, commit the new configuration file
3. If the new build passes your tests, commit the new config file
4 changes: 2 additions & 2 deletions docs/use-cases/submodules.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ While Git [submodules](http://git-scm.com/docs/git-submodule) are an obvious cho

## An Existing Submodule

When managing a single dependency using submodules, there will be two items in your working tree with special meaning. The `.gitmodules` file, which contains submodule configuration, and semi-ignored directory containing the checked out dependency:
When managing a single dependency using submodules, there will be two items in your working tree with special meaning. The `.gitmodules` file, which contains submodule config, and semi-ignored directory containing the checked out dependency:

```sh
<root>/vendor/my_dependency # submodule at: a943a702d06f34599aee1f8da8ef9f7296031d69
Expand Down Expand Up @@ -39,4 +39,4 @@ In other working trees, simply run `$ gitman install` to check out the source de

### Modifying Dependencies

To include a different version of a dependency, modify the `rev` value in the configuration file.
To include a different version of a dependency, modify the `rev` value in the config file.
2 changes: 1 addition & 1 deletion gitman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys

__project__ = 'GitMan'
__version__ = '1.3'
__version__ = '1.4'

CLI = 'gitman'
PLUGIN = 'deps'
Expand Down
4 changes: 2 additions & 2 deletions gitman/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def main(args=None, function=None): # pylint: disable=too-many-statements
subs = parser.add_subparsers(help="", dest='command', metavar="<command>")

# Init parser
info = "create a new configuration file for the project"
info = "create a new config file for the project"
sub = subs.add_parser('init', description=info.capitalize() + '.',
help=info, parents=[debug], **shared)

Expand Down Expand Up @@ -108,7 +108,7 @@ def main(args=None, function=None): # pylint: disable=too-many-statements
help="display the path of the log file")

# Edit parser
info = "open the configuration file in the default editor"
info = "open the config file in the default editor"
sub = subs.add_parser('edit', description=info.capitalize() + '.',
help=info, parents=[debug, project], **shared)

Expand Down
53 changes: 9 additions & 44 deletions gitman/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ def wrapped(*args, **kwargs):


def init():
"""Create a new configuration file for the project."""
"""Create a new config file for the project."""
success = False

config = load_config()

if config:
msg = "Configuration file already exists: {}".format(config.path)
common.show(msg, color='error')
Expand All @@ -39,11 +40,11 @@ def init():
config.sources_locked.append(source)
config.save()

msg = "Created sample configuration file: {}".format(config.path)
msg = "Created sample config file: {}".format(config.path)
common.show(msg, color='success')
success = True

msg = "To edit this configuration file, run: gitman edit"
msg = "To edit this config file, run: gitman edit"
common.show(msg, color='message')

return success
Expand All @@ -70,7 +71,6 @@ def install(*names, root=None, depth=None,
', '.join(names) if names else '<all>')
count = None

root = _find_root(root)
config = load_config(root)

if config:
Expand Down Expand Up @@ -111,7 +111,6 @@ def update(*names, root=None, depth=None,
', '.join(names) if names else '<all>')
count = None

root = _find_root(root)
config = load_config(root)

if config:
Expand Down Expand Up @@ -166,7 +165,6 @@ def display(*, root=None, depth=None, allow_dirty=True):
log.info("Displaying dependencies...")
count = None

root = _find_root(root)
config = load_config(root)

if config:
Expand Down Expand Up @@ -198,7 +196,6 @@ def lock(*names, root=None):
log.info("Locking dependencies...")
count = None

root = _find_root(root)
config = load_config(root)

if config:
Expand All @@ -224,7 +221,6 @@ def delete(*, root=None, force=False):
log.info("Deleting dependencies...")
count = None

root = _find_root(root)
config = load_config(root)

if config:
Expand All @@ -250,10 +246,10 @@ def show(*names, root=None):
"""
log.info("Finding paths...")

root = _find_root(root)
config = load_config(root)

if not config:
log.error("No configuration found")
log.error("No config found")
return False

for name in names or [None]:
Expand All @@ -270,48 +266,17 @@ def edit(*, root=None):
- `root`: specifies the path to the root working tree
"""
log.info("Launching configuration...")
log.info("Launching config...")

root = _find_root(root)
config = load_config(root)

if not config:
log.error("No configuration found")
log.error("No config found")
return False

return system.launch(config.path)


def _find_root(base, cwd=None):
if cwd is None:
cwd = os.getcwd()
log.info("Current directory: %s", cwd)

if base:
root = os.path.abspath(base)
log.info("Specified root: %s", root)

else:
log.info("Searching for root...")
path = cwd
prev = None
root = None
while path != prev:
log.debug("Checking path: %s", path)
if '.git' in os.listdir(path):
root = path
break
prev = path
path = os.path.dirname(path)

if root:
log.info("Found root: %s", root)
else:
root = cwd
log.warning("No root found, default: %s", root)

return root


def _display_result(present, past, count, allow_zero=False):
"""Convert a command's dependency count to a return status.
Expand Down
2 changes: 1 addition & 1 deletion gitman/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def positive_int(value):


class _Config:
"""Share configuration options."""
"""Share logging options."""

MAX_VERBOSITY = 4

Expand Down
2 changes: 1 addition & 1 deletion gitman/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class InvalidConfig(ValueError):
"""Raised when the configuration file is invalid."""
"""Raised when the config file is invalid."""


class ShellError(RuntimeError):
Expand Down
7 changes: 2 additions & 5 deletions gitman/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import logging
from contextlib import suppress

from . import common
from . import common, settings
from .shell import call
from .exceptions import ShellError

Expand All @@ -16,13 +16,10 @@ def git(*args, **kwargs):
return call('git', *args, **kwargs)


def clone(repo, path, *, cache=None):
def clone(repo, path, *, cache=settings.CACHE):
"""Clone a new Git repository."""
log.debug("Creating a new repository...")

cache = cache or os.path.expanduser("~/.gitcache")
cache = os.path.normpath(cache)

name = repo.split('/')[-1]
if name.endswith(".git"):
name = name[:-4]
Expand Down
2 changes: 0 additions & 2 deletions gitman/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
"""Domain models for interacting with dependency configuration."""

from .source import Source
from .config import Config, load_config
Loading

0 comments on commit cbeb731

Please sign in to comment.