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

fix: get_staging_dirs() should return a consistent ordering #1050

Merged
merged 1 commit into from
Apr 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion synthtool/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ def replace(

def get_staging_dirs(default_version: Optional[str] = None) -> List[Path]:
"""Returns the list of directories, one per version, copied from
https://github.com/googleapis/googleapis-gen.
https://github.com/googleapis/googleapis-gen. Will return in lexical sorting
order with the exception of the default_version which will be last (if specified).

Args:
default_version: the default version of the API. The directory for this version
Expand All @@ -294,6 +295,7 @@ def get_staging_dirs(default_version: Optional[str] = None) -> List[Path]:
versions = [v.name for v in staging.iterdir() if v.is_dir()]
# Reorder the versions so the default version always comes last.
versions = [v for v in versions if v != default_version]
versions.sort()
if default_version is not None:
versions += [default_version]
dirs = [staging / v for v in versions]
Expand Down
2 changes: 0 additions & 2 deletions tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,4 @@ def change_test_dir():
def test_get_staging_dirs(change_test_dir):
assert [path.name for path in transforms.get_staging_dirs("v1")] == ["v2", "v1"]
assert [path.name for path in transforms.get_staging_dirs("v2")] == ["v1", "v2"]
paths = [path.name for path in transforms.get_staging_dirs()]
paths.sort()
assert [path.name for path in transforms.get_staging_dirs()] == ["v1", "v2"]