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

Implement b2 file unhide command #297

Merged
merged 17 commits into from
Jul 30, 2024

Conversation

adil-reef
Copy link

Implement b2 file unhide command

b2/_internal/console_tool.py Outdated Show resolved Hide resolved
b2/_internal/console_tool.py Outdated Show resolved Hide resolved
@classmethod
def _setup_parser(cls, parser):
add_bucket_name_argument(parser)
parser.add_argument('fileName').completer = file_name_completer

Choose a reason for hiding this comment

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

seems like there was oversight on our part an we did not update b2 file hide to use B2URI when doing b2v4

Please correct our mistake, i.e.:

  • in this command only support b2uri argument
  • in b2 file hide support both new and old syntax, but the --help should be only speaking of new syntax
  • the b2v3 hide-file should remain unchanged

changelog.d/+b2_file_hide.changed.md Outdated Show resolved Hide resolved
changelog.d/+b2_file_hide.changed.md Outdated Show resolved Hide resolved
changelog.d/+b2_file_unhide.added.md Outdated Show resolved Hide resolved
@@ -712,6 +713,20 @@ def get_b2_uri_from_arg(self, args: argparse.Namespace) -> B2URIBase:
return args.B2_URI


class B2URIFileOrBucketNameArgMixin:

Choose a reason for hiding this comment

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

Suggested change
class B2URIFileOrBucketNameArgMixin:
class B2URIFileOrBucketNameFileNameArgMixin:

and move

def _setup_parser(cls, parser):
        parser.add_argument(
            'fileName', nargs='?', help=argparse.SUPPRESS
        )

in here as well

and drop completer - it will simply not work properly since the first argument will be completed using B2 URI completer

and I guess we have no need for add_b2id_or_file_like_b2_uri_or_bucket_name_argument

I don't know any command that takes either B2URI or plain bucketName, in general we are pushing towards using B2 URI always.

Comment on lines +2144 to +2146
console_tool.run_command(['b2', 'file', 'hide', 'b2://my-bucket/1/hidden1'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/hidden1'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/hidden1'])
console_tool.run_command(['b2', 'file', 'hide', 'my-bucket', '1/hidden2'])
console_tool.run_command(['b2', 'file', 'hide', 'b2://my-bucket/1/hidden2'])

Choose a reason for hiding this comment

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

please create a new unit test that check just legacy syntax since it is rather complex right now to determine whenever the "fileCount": 28, is correct or not and mixing more cases in single tests makes it even more complex

That test can simply create a file, execute legacy hide command and check if the is indeed hidden

@mjurbanski-reef mjurbanski-reef merged commit 9f6127f into reef-technologies:master Jul 30, 2024
30 checks passed
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.

3 participants