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

Cleanup and fix management commands. #256

Closed
wants to merge 1 commit into from
Closed

Cleanup and fix management commands. #256

wants to merge 1 commit into from

Conversation

vil-s
Copy link

@vil-s vil-s commented Sep 4, 2017

  • Ensure that new switch is not created unless the --create flag is passed.
  • Add tests to ensure no regression for the --create fix on all commands.
  • Add separate positional arguments for commands (instead of "positionals") to improve the --help documentation.

Copy link
Collaborator

@clintonb clintonb left a comment

Choose a reason for hiding this comment

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

Please squash your commits.

parser.add_argument(
'-l', '--list',
action='store_true',
dest='list_flags',
default=False,
help="List existing samples."),
help="List existing samples.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Single quotes

parser.add_argument(
'--everyone',
action='store_true',
dest='everyone',
help="Activate flag for all users."),
help="Activate flag for all users.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Single quotes

parser.add_argument(
'--deactivate',
action='store_false',
dest='everyone',
help="Deactivate flag for all users."),
help="Deactivate flag for all users.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Single quotes

@@ -51,7 +60,7 @@ def handle(self, *args, **options):
try:
sample = Sample.objects.get(name=sample_name)
except Sample.DoesNotExist:
raise CommandError('This sample does not exist.')
raise CommandError("This sample doesn't exist.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Single quotes. I find "does not" to be more understandable (esp. for non-native English speakers) than "doesn't".

""" The command shouldn't create a new flag if the create flag is
not set.
"""
with self.assertRaisesRegexp(CommandError, "This flag doesn't exist."):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Applicable to all of your new tests:

  1. Use single quotes to maintain consistency.
  2. Add an assertion that actually ensures the flag/switch/sample does not exist.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fwiw, I strongly prefer double quotes when the string has apostrophes in it, to avoid awkward escape sequences:

'don\'t do this if it can be avoided'
"this's better"
'but this is best'

@vil-s
Copy link
Author

vil-s commented Sep 4, 2017

Review changes implemented

Copy link
Collaborator

@clintonb clintonb left a comment

Choose a reason for hiding this comment

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

Correct the tests.

not set.
"""
name = 'test'
self.assertFalse(Flag.objects.filter(name=name).exists())
Copy link
Collaborator

Choose a reason for hiding this comment

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

The assertions should come after the calls to the management command. The purpose of the test is to ensure the command doesn't create a new instance.

Copy link
Author

Choose a reason for hiding this comment

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

aha, I misunderstood your previous comment

@codeadict
Copy link

This will be a very nice to have.

@stale
Copy link

stale bot commented Oct 22, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Oct 22, 2017
@vil-s
Copy link
Author

vil-s commented Oct 23, 2017

@clintonb I fixed the tests and fixed the merge conflicts. It should be ready to go now.

@clintonb
Copy link
Collaborator

@unklphil please rebase on the master branch, rather than merge master into your own branch. Once that is done, I'll merge.

@aehlke
Copy link

aehlke commented Oct 25, 2017

Just curious why rebasing/squashing in PRs is critical now that github allows squashing as an option in the merge button?

@clintonb
Copy link
Collaborator

This project using the "Rebase and merge" option solely. That decision for this project wasn't mine, but I agree with it. Merging introduces merge bubbles which are mostly noise. Squashing assumes that every PR should be squashed into a single commit when. The decision to use a single commit is not always applicable. If I happen to fix two separate bugs, they should be two separate commits.

In this case, since "Rebase and merge" is the only option available to me, the branch needs to be properly rebased. GitHub will not allow the PR to be merged without a rebase.

screen shot 2017-10-24 at 11 09 58 pm

@aehlke
Copy link

aehlke commented Oct 25, 2017

Thank you, I appreciate the detailed response - I've wondered about this, that makes sense now!

- Ensure that new switch is not created unless the --create flag is passed.
- Add tests to ensure no regression for the --create fix on all commands.
- Add separate positional arguments for commands (instead of "positionals") to improve the --help documentation.
@vil-s
Copy link
Author

vil-s commented Oct 25, 2017

I used the wrong damned option for resolving management.commands.waffle_switch after squashing and rebasing (I was certain that "use mine" would use mine, but it didn't) and did git push --force, and now those changes are lost.

I really don't feel like fixing it, so I'm going to close the issue this PR because it's too much of a hassle for me.

@vil-s vil-s closed this Oct 25, 2017
@jsocol
Copy link
Collaborator

jsocol commented Oct 25, 2017

Ugh, I'm sorry, that's the worst!

If you haven't deleted the local checkout, it may be possible to recover, if you want—or for a future situation—via the git reflog. It can fix things like accidental rebases, recover things that have been forced-pushed over, etc. There be dragons but it's a very powerful tool.

@vil-s
Copy link
Author

vil-s commented Oct 25, 2017

I'll check tomorrow if it's salvagable

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

5 participants