Skip to content

Commit

Permalink
fix: get_staging_dirs() should return a consistent ordering (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
chingor13 authored Apr 16, 2021
1 parent 898b38a commit 6e83224
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
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"]

0 comments on commit 6e83224

Please sign in to comment.