Following the principals of https://nedbatchelder.com/text/unipain.html
our goal is to decode bytes in to unicode as soon as we read them and
encode unicode date to bytes at the last second.
The specific problem we were seeing was caused by calling "encode" on a
byte string rather than a unicode string. Python attempts to be
"helpful" and tries to decode the bytes as ASCII in order to provide a
unicode string to the encode function. Since the bytes aren't ASCII,
the decode fails and we get the UnicodeDecodeError despite the fact that
we never explicitly asked for a decode at all.
Also, calculate checksums correctly for tarballs that have files with
UTF8 characters in the file name.
CentOS 6 only has Python 2.6 available, on which the unit testing
frameworks do not expose a `.assertIn()` helper method. Instead, we can
use `.assertTrue(x in y)`.
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
When tests fail, artifacts from that tests are necessary to properly
debug the failure and determine how to fix the test. This is impossible
when artifacts are immediately removed after the test is finished.
Instead, the tests should remove old artifacts before the test run
begins.
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
When multiple tags exist for one version of a project, or when a version
is passed to `tito tag --use-version` that does not exactly correspond
with a tag in the repository's git history, the auto-generated release
is not guaranteed to monotonically increase. In order for users to
overcome this issue without building complicated logic into `tito`, it
is simpler to allow users to provide a literal release string to use.
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
By using a user specific URL, multiple members of the same team can
submit Copr releases without having to share credentials to the SRPM
remote location. For example, each member of the team can set
COPR_REMOTE_LOCATION in .titorc to their <username>.fedorapeople.org
space.
3892359 changed builder args to always be arrays, so concatenation of
rpmbuild options with other strings then failed.
File "/usr/lib/python2.7/site-packages/tito/release/main.py", line 530, in _koji_release
builder.srpm(dist=disttag)
File "/usr/lib/python2.7/site-packages/tito/builder/main.py", line 210, in srpm
rpmbuild_options = self.rpmbuild_options + self._scl_to_rpmbuild_option()
TypeError: can only concatenate list (not "str") to list
Change builder args to be joined by a single space, allowing multiple
arguments to be passed in.
These tests began failing after a correction to another test. The
other test had been patching the error_out function without unpatching
it and thus polluted the test environment.
Also reset to a known directory at the beginning of the common tests so
that we don't start in a directory that has since been unlinked.
The Maven-generated tar file deviates from the spec in several places.
Fields are padded out with spaces instead of NUL bytes and the user and
group ID are left empty.
This patch alters the tar module to correct these issues and ensures a
consistent unchanging fingerprint for the archive by setting the mtime
on the files to the modified time of the commit.
The Python 2.4 style of getting an exception object is forbidden by the
test_exceptions_3 test. Something has to give, and Tito is not being
built for RHEL 5 anymore.
Python's read(N) function only guarantees that it will read no more
than N bytes but not that it will return N bytes. This patch adds a
function that will ensure exactly N bytes are read.
Tito passes "git archive" a tree ID. The "git archive" man page states:
git archive behaves differently when given a tree ID versus when
given a commit ID or tag ID. In the first case the current time
is used as the modification time of each file in the archive.
Using the current time means that every time we build the source
tarball, the file fingerprint will change since the metadata in the
tarball changes. We don't want that since build systems track the
fingerprint to see if the actual source has changed.
This process was previously handled in an enigmatic Perl script that
lacked any comments whatsoever. Converting it to well-commented Python
makes the process less mysterious and speedier since Tito doesn't need
to shell out to Perl.
Instead of being a command line-only option, the string of extra rpmbuild
arguments can now be passed in via the general builder args mechanism, so it
can even be configured from releasers.conf.
Fixes#155
Fixes issue where just build srpm would be deleted as too old if
building for a newer looking disttag in mock. (i.e. f20 building for
f21)
Also generates more correct looking SRPMs in all cases.