def check_prune(defconfig): msg = git.commit_message('HEAD') restriction = None data = None for line in msg.split('\n'): # handle RFC 822 style folded lines if data and line[0].isspace(): data += line[1:] continue else: data = line kv = data.split('=', 1) data = '' if len(kv) != 2: continue k, v = kv if k == 'restriction': restriction = v if restriction != 'nopublic': return 0 # if we want the top-most patch to have no public changes, # remember where we were commit = git.rev_parse() # first reset to the previous patch: git.reset(["-q", "--hard", "HEAD~1"]) git.clean(['-fdxq']) # then prune, commit and remember the state prune(defconfig, False, '.') git.commit_all("prune test", env={ 'GIT_COMMITTER_NAME': 'prune tester', 'GIT_COMMITTER_EMAIL': '', 'GIT_AUTHOR_NAME': 'prune tester', 'GIT_AUTHOR_EMAIL': '', }) pruned_prev = git.rev_parse() # go back to the top commit git.reset(["-q", "--hard", commit]) git.clean(['-fdxq']) # prune this one again prune(defconfig, False, '.') # reset to the previous prune git.reset([pruned_prev]) # and check if anything is left: if git.is_modified(): print("FAILURE: restriction=nopublic patch modifies prune tree") subprocess.call(['git', 'diff']) ret = 1 else: ret = 0 # eases development: git.reset(["-q", "--hard", commit]) return ret
def _check_fixes(v, req): """fixes=<changeid|unknown>""" if v == "unknown": return True # log origin/master to avoid having a patch that fixes a previous uncommitted # patch that should just be squashed instead orig_owner = git.log(options=[ '--basic-regexp', '--grep', '^Change-Id: *%s$' % v, '--pretty=format:%ae', 'origin/master' ]) if not orig_owner: print 'fixes= change-id doesn\'t exist (yet) (or did you mean "unknown"?)' return False if 'JENKINS_HOME' in os.environ: subprocess.call([ 'ssh', 'git-amr-3.devtools.intel.com', 'gerrit', 'set-reviewers', '-a', orig_owner, git.rev_parse('HEAD') ]) return True
def monitor_chromeos(addrs): cachedir = CACHEDIR if not cachedir: cachedir = os.path.join(os.getcwd(), '..', 'kernel-cache') if not os.path.isdir(cachedir): git.clone(DBTREE, cachedir, options=['--quiet', '--bare']) git.set_origin(DBTREE, cachedir) git.remote_update(cachedir) os.chdir(cachedir) db = git.commit_message('origin/monitor').split('\n') for line in db: for v in VERSIONS: if line.startswith(v.kbranch + ': '): v.start = line.split(': ')[1] prev = None tree_id = git.get_commit_var('origin/monitor', 'T') parent_id = git.rev_parse('origin/monitor') db = [] any_changes = False for v in VERSIONS: if v.ktree != prev: git.set_origin(v.ktree, cachedir) git.remote_update(cachedir) prev = v.ktree range = 'origin/' + v.kbranch if v.start: range = v.start + '..' + range try: log = git.log([ range, '--', 'drivers/net/wireless%s/iwl7000' % v.wifiversion ]) except: # maybe they rebased? try again w/o start range = 'origin/' + v.kbranch log = git.log([ range, '--', 'drivers/net/wireless%s/iwl7000' % v.wifiversion ]) if log: msg = MIMEText(log) msg['Subject'] = 'new changes in %s' % v.kbranch msg['From'] = '*****@*****.**' msg['To'] = ', '.join(addrs) s = smtplib.SMTP(SMTPSERVER) s.sendmail('*****@*****.**', addrs, msg.as_string()) s.quit() any_changes = True db.append(v.kbranch + ': ' + git.rev_parse('origin/%s' % v.kbranch)) db = ['update commit tracker', ''] + db + [''] msg = '\n'.join(db) git.set_origin(DBTREE) if any_changes: new_tree_id = git.commit_tree(tree_id, [parent_id], msg, env={ 'GIT_AUTHOR_NAME': 'cros-monitor', 'GIT_AUTHOR_EMAIL': '', 'GIT_COMMITTER_NAME': 'cros-monitor', 'GIT_COMMITTER_EMAIL': '', }) git.push(['origin', '%s:monitor' % new_tree_id])
def monitor_chromeos(jira): n_tickets = 0 cachedir = CACHEDIR if not cachedir: cachedir = os.path.join(os.getcwd(), '..', 'kernel-cache') if not os.path.isdir(cachedir): debug("Clone database tree to %s..." % cachedir) git.clone(DBTREE, cachedir, options=['--quiet', '--bare']) git.set_origin(DBTREE, cachedir) debug("Update database tree ...") git.remote_update(cachedir) os.chdir(cachedir) db = git.commit_message('origin/monitor').split('\n') for line in db: for v in VERSIONS: if line.startswith(v.kbranch + ': '): v.start = line.split(': ')[1] prev = None tree_id = git.get_commit_var('origin/monitor', 'T') parent_id = git.rev_parse('origin/monitor') db = [] any_changes = False for v in VERSIONS: if v.ktree != prev: git.set_origin(v.ktree, cachedir) debug("Update kernel tree to %s" % v.ktree) git.remote_update(cachedir, env={'https_proxy': PROXY}) prev = v.ktree range = 'origin/' + v.kbranch if v.start: range = v.start + '..' + range log_args_front = [ '--no-merges', '--invert-grep', '--grep=iwl7000-tree:', ] log_args_back = [ '--', 'drivers/net/wireless/iwl7000', ] try: log = git.log(log_args_front + [range] + log_args_back) except: # maybe they rebased? try again w/o start range = 'origin/' + v.kbranch log = git.log(log_args_front + [range] + log_args_back) if log: any_changes = True # create a jira ticket with this info date = time.strftime('%Y-%m-%d') fields = { 'summary': '[%s] google changed tree %s' % (v.kbranch, date), 'description': '{noformat}\n%s\n{noformat}\n' % log, } fields.update(COMMON_JIRA_FIELDS) debug("creating new ticket ...") ticket = jira.create_issue(fields=fields) for watcher in WATCHERS: jira.add_watcher(ticket, watcher) jira.assign_issue(ticket, ASSIGNEE) debug("created ticket %s" % ticket) db.append(v.kbranch + ': ' + git.rev_parse('origin/%s' % v.kbranch)) db = ['update commit tracker', ''] + db + [''] msg = '\n'.join(db) git.set_origin(DBTREE) if any_changes: new_tree_id = git.commit_tree(tree_id, [parent_id], msg, env={ 'GIT_AUTHOR_NAME': 'cros-monitor', 'GIT_AUTHOR_EMAIL': '', 'GIT_COMMITTER_NAME': 'cros-monitor', 'GIT_COMMITTER_EMAIL': '', }) git.push(['origin', '%s:monitor' % new_tree_id])