[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2020-02-21 Thread Guilhem Moulin (via logerrit)
 gerrit/auto-submit/gerrit-autosubmit |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 84a335d47a0b0e49f88447135d6d8ae60c198344
Author: Guilhem Moulin 
AuthorDate: Tue Feb 18 04:05:25 2020 +0100
Commit: Miklos Vajna 
CommitDate: Fri Feb 21 09:09:14 2020 +0100

gerrit-autosubmit: subscribe to "comment-added" events only

No need to stream everything happening on the sever if other event types
are being filtered client-side anyway :-)

Change-Id: I98e6d510eec976143c731df59dd949098cde2ccb
Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/88915
Reviewed-by: Miklos Vajna 
Tested-by: Miklos Vajna 

diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
index fec0bd2..802fbf8 100755
--- a/gerrit/auto-submit/gerrit-autosubmit
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -27,7 +27,8 @@ if port != None and port != "":
 sshcommand.extend(["-p", port])
 
 while True:
-cmd = sshcommand + ["-n", "-o", "ServerAliveInterval=5", server, "gerrit", 
"stream-events"]
+cmd = sshcommand + ["-n", "-o", "ServerAliveInterval=5", server, "gerrit",
+"stream-events", "-s", "comment-added"]
 sock = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1)
 
 try:
@@ -35,7 +36,7 @@ while True:
 event = json.loads(line)
 
 if event['type'] != "comment-added":
-continue
+continue # should never happen
 if 'username' not in event['change']['owner'].keys():
 continue
 if event['change']['owner']['username'] != os.environ['USER']:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2020-02-19 Thread Guilhem Moulin (via logerrit)
 gerrit/auto-submit/gerrit-autosubmit |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 7cd868c5f48f7138eb2d6f9e16ca1db74e0db492
Author: Guilhem Moulin 
AuthorDate: Tue Feb 18 03:37:18 2020 +0100
Commit: Miklos Vajna 
CommitDate: Thu Feb 20 08:46:02 2020 +0100

gerrit-autosubmit: redirect background SSH's stdin from /dev/null

Without that there is a risk of stdin pollution between the two
commands.  Moreover on multiplexed connection the background command
might be lingering around once the script terminates, and without
redirection it starts grabs the parent shell's stdin.

That flag predates the initial revision in OpenSSH's code repository in
1999, so should be safe to use on all systems :-)

Change-Id: I820338385808938396b02470130632cc3df1b473
Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/88914
Tested-by: Miklos Vajna 
Reviewed-by: Miklos Vajna 

diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
index ca231e5..fec0bd2 100755
--- a/gerrit/auto-submit/gerrit-autosubmit
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -27,7 +27,7 @@ if port != None and port != "":
 sshcommand.extend(["-p", port])
 
 while True:
-cmd = sshcommand + ["-o", "ServerAliveInterval=5", server, "gerrit", 
"stream-events"]
+cmd = sshcommand + ["-n", "-o", "ServerAliveInterval=5", server, "gerrit", 
"stream-events"]
 sock = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1)
 
 try:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2020-02-19 Thread Guilhem Moulin (via logerrit)
 gerrit/auto-submit/gerrit-autosubmit |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit ba70f3ba11b115793b96ccc27dbbec4a632a7122
Author: Guilhem Moulin 
AuthorDate: Tue Feb 18 03:17:15 2020 +0100
Commit: Miklos Vajna 
CommitDate: Wed Feb 19 09:05:29 2020 +0100

gerrit-autosubmit: honor `gerrit.port` setting

Change-Id: Iddda4e3d4ceb39ad6c1f57b865509b98ff29e6af
Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/88913
Tested-by: Miklos Vajna 
Reviewed-by: Miklos Vajna 

diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
index 2d40e23..ca231e5 100755
--- a/gerrit/auto-submit/gerrit-autosubmit
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -18,11 +18,16 @@ def get_config(key):
 return ret.decode("utf-8")
 
 server = get_config("gerrit.host")
+port = get_config("gerrit.port")
 project = get_config("gerrit.project")
 branch = get_config("gerrit.defaultbranch")
 
+sshcommand = ["ssh"]
+if port != None and port != "":
+sshcommand.extend(["-p", port])
+
 while True:
-cmd = ["ssh", "-o", "ServerAliveInterval=5", server, "gerrit", 
"stream-events"]
+cmd = sshcommand + ["-o", "ServerAliveInterval=5", server, "gerrit", 
"stream-events"]
 sock = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1)
 
 try:
@@ -45,7 +50,7 @@ while True:
 continue
 
 rev = event['patchSet']['revision']
-cmd = ["ssh", server, "gerrit", "review", "-s", rev]
+cmd = sshcommand + [server, "gerrit", "review", "-s", rev]
 print(' '.join(cmd))
 subprocess.call(cmd)
 except KeyboardInterrupt:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2020-02-18 Thread Guilhem Moulin (via logerrit)
 gerrit/auto-submit/gerrit-autosubmit |   13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 9552c9de868e43650cc5a3f0d8e1f312c6c52ea6
Author: Guilhem Moulin 
AuthorDate: Tue Feb 18 03:14:06 2020 +0100
Commit: Miklos Vajna 
CommitDate: Tue Feb 18 09:07:36 2020 +0100

gerrit-autosubmit: port to python3, replace os.system call

Change-Id: I847b4e3ed79cc8a448ee91bbc6d8f7d1b40fdd69
Reviewed-on: https://gerrit.libreoffice.org/c/dev-tools/+/88912
Tested-by: Miklos Vajna 
Reviewed-by: Miklos Vajna 

diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
index fdc998e..2d40e23 100755
--- a/gerrit/auto-submit/gerrit-autosubmit
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -15,14 +15,15 @@ def get_config(key):
 sock = subprocess.Popen(["git", "config", "-f", ".gitreview", key], 
stdout=subprocess.PIPE)
 ret = sock.stdout.readline().strip()
 sock.stdout.close()
-return ret
+return ret.decode("utf-8")
 
 server = get_config("gerrit.host")
 project = get_config("gerrit.project")
 branch = get_config("gerrit.defaultbranch")
 
 while True:
-sock = subprocess.Popen(["ssh", "-o", "ServerAliveInterval=5", server, 
"gerrit", "stream-events"], stdout=subprocess.PIPE, bufsize=1)
+cmd = ["ssh", "-o", "ServerAliveInterval=5", server, "gerrit", 
"stream-events"]
+sock = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1)
 
 try:
 for line in iter(sock.stdout.readline, b''):
@@ -44,9 +45,9 @@ while True:
 continue
 
 rev = event['patchSet']['revision']
-cmd = "ssh " + server + " gerrit review -s " + rev
-print(cmd)
-os.system(cmd)
+cmd = ["ssh", server, "gerrit", "review", "-s", rev]
+print(' '.join(cmd))
+subprocess.call(cmd)
 except KeyboardInterrupt:
 print("Interrupted.")
 break
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2019-05-22 Thread Libreoffice Gerrit user
 gerrit/auto-submit/git-breview |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 75a5ff65f676c8d6f4b60d7f99529ff0fb8b367e
Author: Miklos Vajna 
AuthorDate: Wed May 22 09:29:17 2019 +0200
Commit: Miklos Vajna 
CommitDate: Wed May 22 09:30:27 2019 +0200

git-breview: dont auto-rebase, handle custom port

core.git .gitreview recently removed the logerrit alias, so make sure we
ssh to the gerrit java sshd, not to the underlying host.

Also disable auto-rebase, that would mean once a change is pushed to
gerrit, it's not easy to add follow-up commits without modifying already
pushed commits.

Change-Id: Iefedf2e9b25311b323ee92399f5315f36d1f13fc

diff --git a/gerrit/auto-submit/git-breview b/gerrit/auto-submit/git-breview
index 00d815c..967584a 100755
--- a/gerrit/auto-submit/git-breview
+++ b/gerrit/auto-submit/git-breview
@@ -5,10 +5,11 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 #
 
-if git-review; then
+if git-review -R; then
 rev=$(git rev-parse HEAD)
 host=$(git config -f .gitreview gerrit.host)
-ssh $host gerrit review --code-review=2 $rev
+port=$(git config -f .gitreview gerrit.port)
+ssh -p $port $host gerrit review --code-review=2 $rev
 fi
 
 # vim:set shiftwidth=4 softtabstop=4 expandtab:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2019-01-31 Thread Libreoffice Gerrit user
 gerrit/auto-submit/gerrit-autosubmit |   60 +++
 1 file changed, 33 insertions(+), 27 deletions(-)

New commits:
commit 2b8fec90b689c911593da1e33d76c0144bc7abe7
Author: Miklos Vajna 
AuthorDate: Thu Jan 31 10:15:48 2019 +0100
Commit: Miklos Vajna 
CommitDate: Thu Jan 31 10:15:48 2019 +0100

gerrit-autosubmit: reconnect after ssh disconnect

diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
index 4aa4f1e..fdc998e 100755
--- a/gerrit/auto-submit/gerrit-autosubmit
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -8,6 +8,7 @@
 import json
 import os
 import subprocess
+import time
 
 
 def get_config(key):
@@ -20,33 +21,38 @@ server = get_config("gerrit.host")
 project = get_config("gerrit.project")
 branch = get_config("gerrit.defaultbranch")
 
-sock = subprocess.Popen(["ssh", "-o", "ServerAliveInterval=5", server, 
"gerrit", "stream-events"], stdout=subprocess.PIPE, bufsize=1)
-
-try:
-for line in iter(sock.stdout.readline, b''):
-event = json.loads(line)
-
-if event['type'] != "comment-added":
-continue
-if 'username' not in event['change']['owner'].keys():
-continue
-if event['change']['owner']['username'] != os.environ['USER']:
-continue
-if event['change']['project'] != project:
-continue
-if event['change']['branch'] != branch:
-continue
-if 'approvals' not in event.keys():
-continue
-if len([approval for approval in event['approvals'] if 
approval['type'] == "Verified" and approval['value'] == "1"]) != 1:
-continue
-
-rev = event['patchSet']['revision']
-cmd = "ssh " + server + " gerrit review -s " + rev
-print(cmd)
-os.system(cmd)
-except KeyboardInterrupt:
-print("Interrupted!")
+while True:
+sock = subprocess.Popen(["ssh", "-o", "ServerAliveInterval=5", server, 
"gerrit", "stream-events"], stdout=subprocess.PIPE, bufsize=1)
+
+try:
+for line in iter(sock.stdout.readline, b''):
+event = json.loads(line)
+
+if event['type'] != "comment-added":
+continue
+if 'username' not in event['change']['owner'].keys():
+continue
+if event['change']['owner']['username'] != os.environ['USER']:
+continue
+if event['change']['project'] != project:
+continue
+if event['change']['branch'] != branch:
+continue
+if 'approvals' not in event.keys():
+continue
+if len([approval for approval in event['approvals'] if 
approval['type'] == "Verified" and approval['value'] == "1"]) != 1:
+continue
+
+rev = event['patchSet']['revision']
+cmd = "ssh " + server + " gerrit review -s " + rev
+print(cmd)
+os.system(cmd)
+except KeyboardInterrupt:
+print("Interrupted.")
+break
+
+print("Socket closed, reconnecting.")
+time.sleep(1)
 
 sock.communicate()
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2018-03-27 Thread Miklos Vajna
 gerrit/auto-submit/gerrit-autosubmit |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 51057dedc1be76398d6fadb1bbc7350a5483058c
Author: Miklos Vajna 
Date:   Tue Mar 27 09:04:58 2018 +0200

gerrit-autosubmit: opt in for keep-alive

It seems this reduces the amount of exit-due-to-timeout issues.

Change-Id: I35c52b9d812531f79e5ebf924e578e16df65fa5e

diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
index 4f6f184..4aa4f1e 100755
--- a/gerrit/auto-submit/gerrit-autosubmit
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -20,7 +20,7 @@ server = get_config("gerrit.host")
 project = get_config("gerrit.project")
 branch = get_config("gerrit.defaultbranch")
 
-sock = subprocess.Popen(["ssh", server, "gerrit", "stream-events"], 
stdout=subprocess.PIPE, bufsize=1)
+sock = subprocess.Popen(["ssh", "-o", "ServerAliveInterval=5", server, 
"gerrit", "stream-events"], stdout=subprocess.PIPE, bufsize=1)
 
 try:
 for line in iter(sock.stdout.readline, b''):
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2016-07-28 Thread Miklos Vajna
 gerrit/auto-submit/gerrit-autosubmit |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit a3e908fbbb3a4edb6aeccbb3dd6e1b2d9c7e948e
Author: Miklos Vajna 
Date:   Thu Jul 28 14:24:30 2016 +0200

gerrit-autosubmit: ignore when the owner's username is missing

Change-Id: I2954d8f993f1a3221895a6d5847f59fcad9b8e5f

diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
index 52fc02c..4f6f184 100755
--- a/gerrit/auto-submit/gerrit-autosubmit
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -28,6 +28,8 @@ try:
 
 if event['type'] != "comment-added":
 continue
+if 'username' not in event['change']['owner'].keys():
+continue
 if event['change']['owner']['username'] != os.environ['USER']:
 continue
 if event['change']['project'] != project:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] dev-tools.git: gerrit/auto-submit

2015-06-12 Thread Miklos Vajna
 gerrit/auto-submit/Makefile  |2 +
 gerrit/auto-submit/README|   11 +++
 gerrit/auto-submit/gerrit-autosubmit |   51 +++
 gerrit/auto-submit/git-breview   |   14 +
 4 files changed, 78 insertions(+)

New commits:
commit 306b215b88d63b8963777ed352514808338844ce
Author: Miklos Vajna vmik...@collabora.co.uk
Date:   Fri Jun 12 10:25:46 2015 +0200

gerrit: import two auto-submit scripts I posted to the list earlier

So that they are not hidden in the list archive (Jacobo could not find
it).

Change-Id: I1dacd95b7e28b89b7cf35cb146cc05dff7078e5e

diff --git a/gerrit/auto-submit/Makefile b/gerrit/auto-submit/Makefile
new file mode 100644
index 000..3c0456a
--- /dev/null
+++ b/gerrit/auto-submit/Makefile
@@ -0,0 +1,2 @@
+check:
+   pep8 --ignore=E501 gerrit-autosubmit
diff --git a/gerrit/auto-submit/README b/gerrit/auto-submit/README
new file mode 100644
index 000..f6c2bdd
--- /dev/null
+++ b/gerrit/auto-submit/README
@@ -0,0 +1,11 @@
+In case your workflow is:
+
+1) Push patch to gerrit.
+2) Mark as code-review-+2
+3) Wait for build-verification.
+4) Submit if 3) succeeded.
+
+Then 1) and 2) is handled by git-breview.
+
+gerrit-autosubmit is supposed to be running all the time, then can automate
+4).
diff --git a/gerrit/auto-submit/gerrit-autosubmit 
b/gerrit/auto-submit/gerrit-autosubmit
new file mode 100755
index 000..52fc02c
--- /dev/null
+++ b/gerrit/auto-submit/gerrit-autosubmit
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import json
+import os
+import subprocess
+
+
+def get_config(key):
+sock = subprocess.Popen([git, config, -f, .gitreview, key], 
stdout=subprocess.PIPE)
+ret = sock.stdout.readline().strip()
+sock.stdout.close()
+return ret
+
+server = get_config(gerrit.host)
+project = get_config(gerrit.project)
+branch = get_config(gerrit.defaultbranch)
+
+sock = subprocess.Popen([ssh, server, gerrit, stream-events], 
stdout=subprocess.PIPE, bufsize=1)
+
+try:
+for line in iter(sock.stdout.readline, b''):
+event = json.loads(line)
+
+if event['type'] != comment-added:
+continue
+if event['change']['owner']['username'] != os.environ['USER']:
+continue
+if event['change']['project'] != project:
+continue
+if event['change']['branch'] != branch:
+continue
+if 'approvals' not in event.keys():
+continue
+if len([approval for approval in event['approvals'] if 
approval['type'] == Verified and approval['value'] == 1]) != 1:
+continue
+
+rev = event['patchSet']['revision']
+cmd = ssh  + server +  gerrit review -s  + rev
+print(cmd)
+os.system(cmd)
+except KeyboardInterrupt:
+print(Interrupted!)
+
+sock.communicate()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/gerrit/auto-submit/git-breview b/gerrit/auto-submit/git-breview
new file mode 100755
index 000..00d815c
--- /dev/null
+++ b/gerrit/auto-submit/git-breview
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+if git-review; then
+rev=$(git rev-parse HEAD)
+host=$(git config -f .gitreview gerrit.host)
+ssh $host gerrit review --code-review=2 $rev
+fi
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits