Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dryrun option and fix some other stuff #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bjh83
Copy link
Collaborator

@bjh83 bjh83 commented Nov 18, 2020

Couple of commits here. I can break them up if you want.

First commit adds some more stuff to .gitignore.
Second commit adds a --dryrun option to service, basically runs everything as normal without uploading to Gerrit.
Last commit fixes email decoding.

@dlatypov dlatypov self-requested a review November 18, 2020 22:41
Copy link
Collaborator

@dlatypov dlatypov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM.

The "DryRunClass" as the baseclass seems a bit strange to me, but it works.
Mainly just some nits about the naming there.

@@ -14,7 +14,7 @@

import email
import re
from typing import List, Optional, Tuple
from typing import List, Optional, Tuple, BinaryIO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: BinaryIO is unused in this commit.

except subprocess.CalledProcessError as e:
logging.warning('Failed to push upstream because %s.', e.output)
raise
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I would prefer this DryRunGerritGit to only contain decls + pass

This probably warrants another commit here first to trim down the interface, e.g. rename def push_patch() to def _push_patch()

I think the only thing we want to expose is apply_patchsetup_and_cleanup()?

Then the def would become

class DryRunGerritGit:
     def apply_patchsetup_and_cleanup(...):
          pass

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone ahead and trimmed the interface down as 5adaf15.
So you should just be able to rebase on master.

Might have some merge conflicts (but it felt like those would be unavoidable, even if you made the change yourself)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about that, but I kind of like it still trying to apply patches locally and doing some other stuff. I found it to provide some useful feedback.

@@ -40,7 +40,26 @@ def __call__(self, request: PreparedRequest):
request.prepare_cookies(self.cookie_jar)
return request

class Gerrit(object):

class FakeGerrit(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Perhaps DryRunGerrit

This would more symmetric with GerritGit below (assuming we recapitalize to DryRunGerritGit

@@ -40,7 +40,26 @@ def __call__(self, request: PreparedRequest):
request.prepare_cookies(self.cookie_jar)
return request

class Gerrit(object):

class FakeGerrit(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I am still stuck on Python 2

class GerritGit(object):
def __init__(self, git_dir: str, cookie_jar_path: str, url: str, project: str, branch: str) -> None:

class DryrunGerritGit(object):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps rename to DryRun

Also nit: perhaps drop object, https://google.github.io/styleguide/pyguide.html#39-classes

Ignore several directories that are created when lkml-gerrit-bridge
service runs.

Change-Id: I757cb9363aa59d45bfd087eae82433a16fc313d3
Add --dryrun flag which cause lkml-gerrit-bridge to run as normal with
the exception that it does not upload anything to Gerrit. This is
convenient for testing as it makes it faster *and* does not pollute
Gerrit.

Change-Id: I07e3c5c794a16db8c94e22b1fff7ddae86e0e60e
Handle emails not encoded in utf-8 or ascii.

Change-Id: Ia2cbc75bd0f80afada7c6036043d49dcc4e3e049
@bjh83 bjh83 force-pushed the add-dryrun-option-and-fix-some-other-stuff branch from fc49061 to fc61022 Compare November 19, 2020 21:28
logging.warning('Failed to push upstream because %s.', e.output)
raise

def setup_git_dir(self, clone_depth=1) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this wants to be _setup_git_dir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants