Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 1.34 KB

README.md

File metadata and controls

53 lines (42 loc) · 1.34 KB

python-gerrit

Gerrit bindings for python

The bindings are still a work in progress!

How to use

  • Connect to a server:
    import gerrit
    import paramiko

    pkey = paramiko.RSAKey(filename="/home/foo/.ssh/id_rsa.pub")
    username = "Bob"
    host = "example.com"
    port = 29418  # Default Gerrit ssh port

    g = Gerrit(host, port, username, pkey)
  • Query for changes:
    g = Gerrit(host, port, username, pkey)

    # Query for all changes in project 'bar' including comments
    changes = g.query("project:bar", options=[QueryOptions.Comments])
    for change in changes:
    	print change
  • Add a reviewer:
    g = Gerrit(host, port, username, pkey)

    # Query for all changes in project 'bar' including the current patch-set
    changes = g.query("project:bar", options=[QueryOptions.CurrentPatchSet])
    for change in changes:
    	revision = change['currentPatchSet']['revision']
    	g.set_reviewers(revision, add=[username])
  • Add a review
    g = Gerrit(host, port, username, pkey)

    # Query for all changes in project 'bar' including the current patch-set
    changes = g.query("project:bar", options=[QueryOptions.CurrentPatchSet])
    for change in changes:
    	revision = change['currentPatchSet']['revision']
    	g.review(revision, message="Hello World!")