Skip to content

Commit

Permalink
Merge pull request #5 from mapleoin/travis
Browse files Browse the repository at this point in the history
Awesome
  • Loading branch information
saschpe committed Jan 17, 2013
2 parents 1bb3d78 + c44c25b commit 04bfb48
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
@@ -0,0 +1,10 @@
language: python
python:
- "2.6"
- "2.7"
install:
- pip install -r pip-requires --use-mirrors
- pip install -r test-requires --use-mirrors
script:
- nosetests
- pep8 git_tarballs *py
10 changes: 4 additions & 6 deletions README.rst
Expand Up @@ -22,13 +22,11 @@ On the first run, ``git_tarballs`` will just set the spec file's
be updated with commit message information when newer commits (compared
to the one now set in ``Version``) are found.

Dependencies
------------
Up to date requirements are kept in the files ``pip-requires`` and
``test-requires``

Requires argparse which is part of python2.7, but available as a
third-party dependency in python2.6.

The tests require `python-mock`_. To run them, just use ``nosetests`` or ``python -m unittest discover`` (on python2.7).
To run the testsuite, just use ``nosetests`` or ``python -m unittest
discover`` (on python2.7).

TODO

Expand Down
32 changes: 21 additions & 11 deletions git_tarballs
Expand Up @@ -70,12 +70,14 @@ def get_parent_dir_and_version_from_tarball(tar_name, version_regexp):
"version in '%s': no match" % (version_regexp, parent_dir))
elif len(match.groups()) != 1:
sys.exit("Could not use '%s' as regular expression to find "
"version in '%s': more than one match" % (version_regexp, parent_dir))
"version in '%s': more than one match" %
(version_regexp, parent_dir))
else:
version = match.group(1)

return (parent_dir, version)


def get_upstream_commit(changelog):
try:
return re.search(r'^commit (.*?)$', changelog, re.MULTILINE).group(1)
Expand Down Expand Up @@ -151,9 +153,10 @@ def update_spec_file(package_version, tarball_parent_dir, filename):

def diff_changes(changes_list, package_commit):
"""Return a list of dict changes newer than the ones in package_version
:changes_list: a list of dicts from the ChangeLog file
:package_commit: a git commit hash of the current version from the spec file
:package_commit: a git commit hash of the current version from the
spec file
Returns an empty list if there are no newer commits.
Expand All @@ -173,7 +176,8 @@ def create_changes(changes_list, package_version, package_commit, email):
:changes_list: a list of dicts from the ChangeLog file
:package_version: release version string for the .changes file entry
:package_commit: a git commit hash of the current version from the spec file
:package_commit: a git commit hash of the current version from the
spec file
:email: email address used for the .changes file entry
"""
Expand All @@ -188,8 +192,8 @@ def create_changes(changes_list, package_version, package_commit, email):
commits = " + " + "\n + ".join(c['message'] for c in changes_diff
if not c['message'].startswith('Merge "'))
change = (
'--------------------------------------------------------------------\n'
'%(timestamp)s - %(email)s\n'
'--------------------------------------------------------------------'
'\n%(timestamp)s - %(email)s\n'
'\n'
'- Update to version %(package_version)s:\n'
'%(commits)s\n'
Expand All @@ -199,7 +203,7 @@ def create_changes(changes_list, package_version, package_commit, email):


def update_changes_file(package, changes):
try:
try:
f = open(package + '.changes', 'r+')
contents = f.read()
f.seek(0)
Expand All @@ -218,10 +222,14 @@ if __name__ == '__main__':
parser.add_argument('--package',
help='the OBS package name')
parser.add_argument('--email', required=True,
help='email of the commit author (for the .changes file)')
help='email of the commit author '
'(for the .changes file)')
parser.add_argument('--version-regexp', default='.*-([^-]+)',
help='regular expression for extracting version from top-level directory in tarball (default: ".*-([^-]+)")')
parser.add_argument('--outdir', help='osc service parameter that does nothing')
help='regular expression for extracting version from '
'top-level directory in tarball '
'(default: ".*-([^-]+)")')
parser.add_argument('--outdir',
help='osc service parameter that does nothing')
args = parser.parse_args()

if not args.filename:
Expand All @@ -234,7 +242,9 @@ if __name__ == '__main__':
changelog = get_changelog_from_tarball(args.filename)
changes_list = parse_changelog(changelog)
upstream_commit = get_upstream_commit(changelog)
tarball_parent_dir, upstream_version = get_parent_dir_and_version_from_tarball(args.filename, args.version_regexp)
tarball_parent_dir, upstream_version = \
get_parent_dir_and_version_from_tarball(
args.filename, args.version_regexp)

package_commit = get_commit_from_spec(args.package)
package_version = package_version(upstream_version, upstream_commit)
Expand Down
1 change: 1 addition & 0 deletions pip-requires
@@ -0,0 +1 @@
argparse
3 changes: 3 additions & 0 deletions test-requires
@@ -0,0 +1,3 @@
mock
nose
pep8

0 comments on commit 04bfb48

Please sign in to comment.