Skip to content

Commit

Permalink
Strip whitespace from 'revision' args (#1772)
Browse files Browse the repository at this point in the history
This commit adds a function that strips whitespace from any subcommand
that takes a revision argument.

Co-authored-by: Quentin Pradet <[email protected]>
  • Loading branch information
b-deam and pquentin authored Aug 29, 2023
1 parent 8dae2c3 commit e713173
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions esrally/rally.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def supported_es_version(v):
raise argparse.ArgumentTypeError(f"must be at least {min_es_version} but was {v}")
return v

def revision(v):
return v.strip()

def add_track_source(subparser):
track_source_group = subparser.add_mutually_exclusive_group()
track_source_group.add_argument(
Expand All @@ -114,6 +117,7 @@ def add_track_source(subparser):
"--track-revision",
help="Define a specific revision in the track repository that Rally should use.",
default=None,
type=revision,
)

# try to preload configurable defaults, but this does not work together with `--configuration-name` (which is undocumented anyway)
Expand Down Expand Up @@ -295,6 +299,7 @@ def add_track_source(subparser):
'e.g. "@2013-07-27T10:37:00Z" (default: current). A combination of branch and timestamp is also possible,'
'e.g. "@feature-branch@2023-04-06T14:52:31Z".',
default="current",
type=revision,
) # optimized for local usage, don't fetch sources
build_parser.add_argument(
"--target-os",
Expand All @@ -313,6 +318,7 @@ def add_track_source(subparser):
"--team-revision",
help="Define a specific revision in the team repository that Rally should use.",
default=None,
type=revision,
)
build_parser.add_argument(
"--team-path",
Expand Down Expand Up @@ -355,6 +361,7 @@ def add_track_source(subparser):
"--team-revision",
help="Define a specific revision in the team repository that Rally should use.",
default=None,
type=revision,
)
download_parser.add_argument(
"--team-path",
Expand Down Expand Up @@ -399,6 +406,7 @@ def add_track_source(subparser):
' The timestamp must be specified as: "@ts" where "ts" must be a valid ISO 8601 timestamp, '
'e.g. "@2013-07-27T10:37:00Z" (default: current).',
default="current",
type=revision,
) # optimized for local usage, don't fetch sources
# Intentionally undocumented as we do not consider Docker a fully supported option.
install_parser.add_argument(
Expand All @@ -416,6 +424,7 @@ def add_track_source(subparser):
"--team-revision",
help="Define a specific revision in the team repository that Rally should use.",
default=None,
type=revision,
)
install_parser.add_argument(
"--team-path",
Expand Down Expand Up @@ -571,6 +580,7 @@ def add_track_source(subparser):
"--team-revision",
help="Define a specific revision in the team repository that Rally should use.",
default=None,
type=revision,
)

race_parser.add_argument(
Expand All @@ -591,6 +601,7 @@ def add_track_source(subparser):
' The timestamp must be specified as: "@ts" where "ts" must be a valid ISO 8601 timestamp, '
'e.g. "@2013-07-27T10:37:00Z" (default: current).',
default="current",
type=revision,
) # optimized for local usage, don't fetch sources
add_track_source(race_parser)
race_parser.add_argument(
Expand Down

0 comments on commit e713173

Please sign in to comment.