From afcbd4921844136eb2cb37a806e0b9f65a0281db Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Tue, 22 Jan 2019 15:49:27 -0600 Subject: [PATCH 1/5] Turn down default loglevel to WARNING. Otherwise, you end up with a bunch of INFO/DEBUG lines printed to committer at each push. --- master/contrib/git_buildbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index 3687ece..18588c6 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -436,7 +436,7 @@ def parse_options(): # information to a file as well (we'll set that up later.) stderr = logging.StreamHandler(sys.stderr) fmt = logging.Formatter("git_buildbot: %(levelname)s: %(message)s") -stderr.setLevel(logging.NOTSET) +stderr.setLevel(logging.WARNING) stderr.setFormatter(fmt) logging.getLogger().addHandler(stderr) logging.getLogger().setLevel(logging.NOTSET) From a44f11f0ea43b0446bb61cfd9e3f9d9047d0a4fb Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Tue, 22 Jan 2019 16:30:50 -0600 Subject: [PATCH 2/5] Remove piping and cmd substitution call in Popen cmd. The gen_create_branch_changes() function was building a Popen command that used shell pipes and cmd substitution, however this was causing the script to fail because Popen doesn't interpret the pipes and cmd substitution correctly. Instead, I broke the command up into separate Popen calls and piped them together. --- master/contrib/git_buildbot.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index 18588c6..c1c786c 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -221,15 +221,21 @@ def gen_create_branch_changes(newrev, refname, branch): logging.info("Branch `%s' created", branch) - f = subprocess.Popen(shlex.split("git rev-parse --not --branches" - + "| grep -v $(git rev-parse %s)" % refname - + - "| git rev-list --reverse --pretty=oneline --stdin %s" % newrev), - stdout=subprocess.PIPE) - - gen_changes(f, branch) - - status = f.close() + p = subprocess.Popen(shlex.split("git rev-parse %s" % refname), stdout=subprocess.PIPE) + branchref = p.communicate()[0].strip().decode(encoding) + f = subprocess.Popen(shlex.split("git rev-parse --not --branches"), stdout=subprocess.PIPE) + f2 = subprocess.Popen(shlex.split("grep -v %s" % branchref), + stdin=f.stdout, + stdout=subprocess.PIPE) + f3 = subprocess.Popen( + shlex.split("git rev-list --reverse --pretty=oneline --stdin %s" % newrev), + stdin=f2.stdout, + stdout=subprocess.PIPE + ) + + gen_changes(f3, branch) + + status = f3.returncode if status: logging.warning("git rev-list exited with status %d", status) From 1bcc0318b03cf278b8d7a13a5ed576ba6dc98cdd Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Tue, 22 Jan 2019 17:02:36 -0600 Subject: [PATCH 3/5] Seems like Popen.returncode should be checked here for status. --- master/contrib/git_buildbot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index c1c786c..9ff6259 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -249,7 +249,7 @@ def gen_create_tag_changes(newrev, refname, tag): f = subprocess.Popen(shlex.split("git log -n 1 --pretty=oneline %s" % newrev), stdout=subprocess.PIPE) gen_changes(f, tag) - status = f.close() + status = f.returncode if status: logging.warning("git log exited with status %d", status) @@ -292,7 +292,7 @@ def gen_update_branch_changes(oldrev, newrev, refname, branch): logging.debug(" Rewound file: %s", file) files.append(text_type(file)) - status = f.terminate() + status = f.returncode if status: logging.warning("git diff exited with status %d", status) From 0081772f03e473c9e274b3cfe5eca151d6aa6b3a Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Wed, 23 Jan 2019 15:42:20 -0600 Subject: [PATCH 4/5] Downgrade "No changes" message to info instead of warning. If there really aren't any changes to push to buildbot (i.e. you just deleted a branch or something), I don't see why this should be a warning vs just an info message. --- master/contrib/git_buildbot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index 9ff6259..81041b1 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -382,7 +382,7 @@ def process_changes(): def send_changes(): # Submit the changes, if any if not changes: - logging.warning("No changes found") + logging.info("No changes found") return host, port = master.split(':') From fae7690c79a1fc35f5984c43187ec494d38b00ea Mon Sep 17 00:00:00 2001 From: mrstanwell Date: Fri, 29 Mar 2019 15:30:00 -0500 Subject: [PATCH 5/5] Replace calls to Popen.terminate() and .returncode with .wait(). --- master/contrib/git_buildbot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/master/contrib/git_buildbot.py b/master/contrib/git_buildbot.py index 81041b1..0312fb0 100755 --- a/master/contrib/git_buildbot.py +++ b/master/contrib/git_buildbot.py @@ -177,7 +177,7 @@ def grab_commit_info(c, rev): c['comments'] = ''.join(comments) c['files'] = files - status = f.terminate() + status = f.wait() if status: logging.warning("git show exited with status %d", status) @@ -235,7 +235,7 @@ def gen_create_branch_changes(newrev, refname, branch): gen_changes(f3, branch) - status = f3.returncode + status = f3.wait() if status: logging.warning("git rev-list exited with status %d", status) @@ -249,7 +249,7 @@ def gen_create_tag_changes(newrev, refname, tag): f = subprocess.Popen(shlex.split("git log -n 1 --pretty=oneline %s" % newrev), stdout=subprocess.PIPE) gen_changes(f, tag) - status = f.returncode + status = f.wait() if status: logging.warning("git log exited with status %d", status) @@ -292,7 +292,7 @@ def gen_update_branch_changes(oldrev, newrev, refname, branch): logging.debug(" Rewound file: %s", file) files.append(text_type(file)) - status = f.returncode + status = f.wait() if status: logging.warning("git diff exited with status %d", status) @@ -324,7 +324,7 @@ def gen_update_branch_changes(oldrev, newrev, refname, branch): stdout=subprocess.PIPE) gen_changes(f, branch) - status = f.terminate() + status = f.wait() if status: logging.warning("git rev-list exited with status %d", status)