forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gitiles] Add parse_repo_url function
Add a function to parse a Gitiles repo URL supporting various edge cases. R=tandrii@chromium.org Bug: 877161 Change-Id: Ib4d6a28a2ace2e594f1a4ca31460a446fc6fa052 Reviewed-on: https://chromium-review.googlesource.com/1204914 Commit-Queue: Nodir Turakulov <nodir@chromium.org> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
- Loading branch information
Showing
10 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/a prefix.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"host", | ||
"path/to/project" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"host", | ||
"path/to/project" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/git suffix.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"host", | ||
"path/to/project" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/http and a prefix.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"host", | ||
"path/to/project" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/http.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"host", | ||
"path/to/project" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/no scheme.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"host", | ||
"path/to/project" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/plus.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"None", | ||
"None" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
15 changes: 15 additions & 0 deletions
15
recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/query string param.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[ | ||
{ | ||
"cmd": [ | ||
"echo", | ||
"None", | ||
"None" | ||
], | ||
"name": "build" | ||
}, | ||
{ | ||
"name": "$result", | ||
"recipe_result": null, | ||
"status_code": 0 | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2018 The LUCI Authors. All rights reserved. | ||
# Use of this source code is governed under the Apache License, Version 2.0 | ||
# that can be found in the LICENSE file. | ||
|
||
DEPS = [ | ||
'gitiles', | ||
'recipe_engine/properties', | ||
'recipe_engine/step', | ||
] | ||
|
||
|
||
def RunSteps(api): | ||
repo_url = api.properties['repo_url'] | ||
host, project = api.gitiles.parse_repo_url(repo_url) | ||
api.step('build', ['echo', str(host), str(project)]) | ||
|
||
|
||
def GenTests(api): | ||
|
||
def case(name, repo_url): | ||
return api.test(name) + api.properties(repo_url=repo_url) | ||
|
||
yield case('basic', 'https://host/path/to/project') | ||
yield case('http', 'http://host/path/to/project') | ||
yield case('a prefix', 'https://host/a/path/to/project') | ||
yield case('git suffix', 'https://host/path/to/project.git') | ||
yield case('http and a prefix', 'http://host/a/path/to/project') | ||
yield case('no scheme', 'host/a/path/to/project') | ||
yield case('query string param', 'https://host/a/path/to/project?a=b') | ||
yield case('plus', 'https://host/path/to/project/+/master') |