forked from rebase-helper/rebase-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebase-helper-fedmsg.py
executable file
·64 lines (56 loc) · 2.2 KB
/
rebase-helper-fedmsg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python -tt
# -*- coding: utf-8 -*-
#
# This tool helps you to rebase package to the latest version
# Copyright (C) 2013-2014 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# he Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Authors: Petr Hracek <[email protected]>
# Tomas Hozza <[email protected]>
# It requires fedmsg package
from __future__ import print_function
import sys
import tempfile
import shutil
from rebasehelper.upstream_monitoring import UpstreamMonitoring
if len(sys.argv) != 3:
print ('You have to specify package and new upstream version')
print ('Like rebase-helper-fedmsg <package> <version>')
sys.exit(1)
package = sys.argv[1]
version = sys.argv[2]
tmp = tempfile.mkdtemp(prefix='thn-', dir='/tmp')
rh_stuff = {}
url = 'http://pkgs.fedoraproject.org/cgit/{package}.git'.format(package=package)
try:
import sh
sh.git.clone(url, tmp)
except ImportError:
pass
rh_upstream = UpstreamMonitoring()
rh_upstream.add_upstream_log_file()
rh_upstream.add_thn_info(tmp, package, version)
ret_code, rh_stuff = rh_upstream.process_thn()
if int(ret_code) == 0:
print ('Rebase package %s to %s was SUCCESSFUL.' % (package, version))
else:
ret_code = 1
print ('Rebase package %s to %s FAILED. See for details.' % (package, version))
print ('Koji scratch build is available here: %s' % rh_stuff['build_log'][int(ret_code)])
print ('Information about patches:\n%s' % '\n'.join(rh_stuff['patches']))
print ('Available log files generated by rebase-helper are:\n%s' % '\n'.join(rh_stuff['logs']))
print ('Checkers %s' % rh_stuff['checkers'])
shutil.rmtree(tmp)