GitRepository/strip_sha1: fix length checking

Accept longer sha1 than what was asked for. The length option given to
git is merely a "wish to get a sha1 of this length". Git may also return
longer sha1 if truncating to given length would give
ambiguous/non-unique sha1.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Check the sha1 doesn't exceed 40 bytes
Tristate: allow to init from another Tristate object

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Tristate: drop broken and unused is_valid_state() method

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: 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>
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.

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>