tests.test_GitRepository: import and setup gbp.log

In order to initialize gbp logging properly. Fixes false positives when
the GitRepository tests are run alone.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository/rev_parse: use _git_inout()

instead of the deprecated _git_getoutput() method.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
log: make color setting a tristate on/off/auto

Makes it possible to force color=on e.g. when piping output. Also, moves
all 'auto' logic to one single place, i.e. the streamhandler.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pq: do author guessing outside the apply_patch functions

Call the author parsing/guessing function outside the apply patch
functions. This way, the caller can decide when to do the guessing, and
with which parameters. Now the apply_patch functions do what their name
suggests.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Support unit tests on Ubuntu: allow "ubuntu" as part of version

In tests/11_test_dch_main.py, there are checks for package names. This
change adds "ubuntu" and related release bane strings ORed in regexp
match to the patterns that are expecteds in assert statements.

Signed-off-by: Olev Kartau <olev.kartau@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository/find_tag: add 'longfmt' and 'always' options

Add 'longfmt' for getting the tag name in the long format (tag, number
of commits and sha1) and 'always' for falling back to sha1 if no
(matching) tag name is found.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository/get_remote_repos: return URLs, too

In addition to the remote name, return remote URLs. Return value is now
a dict with remote name as the key and a list of URLs as the value. The
first value in the list is the effective fetch URL, the rest of the
values are push URLs.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository: Implement status method

Simple wrapper to the git-status command.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository: allow repo inititialization from subdir

This allows initialization of a GitRepository object, even if the
current working directory (or path given to GitRepository) is not the
top level directory of the git repository.

Don't guess the git meta data dir, but, take it as reported by git
itself.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tests.testutils: baseclass for testing commandline tools

Introduce a new baseclass to be utilized in testing the git-buildpackage
command line tools.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp.git: Reimplement rfc822 date parsing without dateutil

In order to get rid of dependency to dateutil.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
tests: add test for archiving without git submodules

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
common/buildpackage: support for different archive formats

Adds support for defining the archive format of the output of
git_archive_single(), e.g. 'zip'. Defaults to 'tar', as before.

Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository/_git_inout: implement support for filtering

Support filtering of the output of git command through a python
function.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Change compressor cmdline opts in compressor_opts to a list

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository: rewrite git_archive()

Add support for filtering. That is, allow the caller to pipe the output
of git-archive through a filter command, usually a compression program.
This utilizes the new filtering functionality of the _git_inout()
method.

Also, gets rid of the hackish use of 'cwd' option.

The 'output' is now considered to be relative to the caller's cwd, not
the git repo dir. This should be more intuitive.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
buildpackage/git_archive_single: use GitRepository.archive()

Use GitRepository.archive() method like git_archive_submodules() does.
This makes it possible to call git_archive_single() independent of the
callers current working directory.

Get rid of the pipe in git_archive_single() and utilize the filter
function of archive() method of GitRepository, instead.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
buildpackage/dump_tree: use GitRepository.archive()

Make dump_tree() utilize the GitRepository.archive() method - similarly
to git_archive_submodules() - instead of ad-hoc Python pipes. This makes
dump_tree() work independent of the callers current working directory.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository/get_commit_info: add patchname to info

Add a new 'patchname' field to the information returned by
get_commit_info. That is, the subject in a sanitized format, similar to
what git-format-patch uses.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
GitRepository: add format_patch method

A method for generating one patch, with the possibility to filter the
git patch through a python function.

Always generates textual diffs as the 'patch' utility doesn't support
git binary diffs.

TODO: convert all code to use the new format_patch() and get rid of the
format_patches() method.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>