~racb/git-ubuntu:decouple-gitubunturepository

Last commit made on 2018-02-19
Get this branch:
git clone -b decouple-gitubunturepository https://git.launchpad.net/~racb/git-ubuntu
Only Robie Basak can upload to this branch. If you are Robie Basak please log in for upload directions.

Branch merges

Branch information

Name:
decouple-gitubunturepository
Repository:
lp:~racb/git-ubuntu

Recent commits

b7d356f... by Robie Basak

Prevent modification of GitUbuntuRepository env

Since it is common to take a GitUbuntuRepository instance env property
and then adjust it, make sure that modifying the dictionary returned
from the property getter does not modify the dictionary owned by the
instance itself. This adds some robustness against this common use
pattern.

ebf9415... by Robie Basak

dsc_to_tree_hash: take pygit2.Repository directly

This change should cover all callers. No functional changes.

37bde76... by Robie Basak

Make dir_to_tree a classmethod

This allows callers to use dir_to_tree on a pygit2.Repository directly,
without necessarily having a GitUbuntuRepository instance.

This changes all the callers to supply a pygit2.Repository directly. It
should not result in any functional changes.

e82bb2f... by Robie Basak

dir_to_tree: use top-level git_run

Instead of using the GitUbuntuRepository.git_run method, use the top
level one instead.

This reduces dependency on the state of the GitUbuntuRepository class
instance with the goal of making this method into a classmethod.

This change should result in no functional changes. It does change the
resulting git call from using --work-tree to setting GIT_WORKTREE
instead. However this should not change git's behaviour, and we already
have tests for this method to help ensure this.

bae16fc... by Robie Basak

Add worktree and index support to git_run

Allow the caller to specify a worktree path and/or an index path, and
have the environment automatically set up to use these.

This should have no functional changes. Existing callers who do not
request this should see exactly the same behaviour.

abb9fde... by Robie Basak

Use the top level git_run function

Instead of having two separate implementations, have the
GitUbuntuRepository.git_run method use the top level git_run function
for its implementation.

This should not introduce any functional changes.

The only differences now between the method and the function are:

  1. The caller doesn't have to look up the underlying pygit2.Repository
     on the GitUbuntuRepository directly, so it's a useful shortcut.

  2. To preserve existing behaviour that currently doesn't have tests,
     the method uses an initial environment identical to the process
     environment at the time of construction of the GitUbuntuRepository
     instance, instead of the environment at the time of the functional
     call. This is intentionally left for a future change to simplify
     things after we have better test coverage.

a5e4cce... by Robie Basak

git_run method: use _derive_git_cli_env directly

This moves us towards centralising the call to the git CLI via a top
level function.

This should not introduce any functional changes.

b81bd31... by Robie Basak

Use module-level git CLI env derivation

Provide git CLI environment derivation in one central place that
does not need a GitUbuntuRepository instance to operate.

1bc06c8... by Robie Basak

Add GitUbuntuRepository.git_run docstring

4d1d2bd... by Robie Basak

Replace self._env with a derived property

As part of the drive to reduce stored state to improve testability,
derive self.env when we need it instead of working out in advance in the
constructor.

This is intended to have no functional changes.

GIT_WORK_TREE will end up differently normalised now, such as in
trailing slashes, since in testing pygit2.Repository.workdir was not
normalised like this and so a normalised assertion was needed. This
should not result in any change to git's behaviour.