-
Notifications
You must be signed in to change notification settings - Fork 1k
build(deps): Bump the go group across 1 directory with 18 updates #1686
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ca73e2b
build(deps): Bump the go group across 1 directory with 18 updates
dependabot[bot] 0fb45bf
Patch harmless parts of go.mod before looking for changes in CI.
felixfontein 83ecd25
Run 'make vendor' in CodeQL build step.
felixfontein 0406503
Move Python patch tool to .github/utils/.
felixfontein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,77 @@ | ||
| """ | ||
| Patch go.mod so that the lines 'go xxx' to 'toolchain xxx' are as in git's | ||
| HEAD. | ||
|
|
||
| This is necessary since newer 'go mod tidy' versions tend to modify these | ||
| lines. Since we check in CI that 'go mod tidy' does not change go.mod, this | ||
| causes CI to fail. | ||
| """ | ||
|
|
||
| import subprocess | ||
|
|
||
|
|
||
| def split_go_mod(contents: str) -> tuple[list[str], list[str], list[str]]: | ||
| """ | ||
| Given the contents of go.mod, splits it into three lists of lines | ||
| (with endings): | ||
| 1. The lines before 'go'; | ||
| 2. The lines starting with 'go' and ending with 'toolchain'; | ||
| 3. The lines after 'toolchain'. | ||
| """ | ||
| parts: tuple[list[str], list[str], list[str]] = ([], [], []) | ||
| index = 0 | ||
| for line in contents.splitlines(keepends=True): | ||
| next_index = index | ||
| if line.startswith('go '): | ||
| index = next_index = 1 | ||
| if line.startswith('toolchain '): | ||
| next_index = 2 | ||
| parts[index].append(line) | ||
| index = next_index | ||
| return parts | ||
|
|
||
|
|
||
| def get_file_contents_from_git_revision(filename: str, revision: str) -> str: | ||
| """ | ||
| Get the file contents of ``filename`` from Git revision ``revision``. | ||
| """ | ||
| p = subprocess.run( | ||
| ['git', 'show', f'{revision}:{filename}'], | ||
| stdout=subprocess.PIPE, | ||
| check=True, | ||
| encoding='utf-8', | ||
| ) | ||
| return p.stdout | ||
|
|
||
|
|
||
| def read_file(filename: str) -> str: | ||
| """ | ||
| Read the file's contents. | ||
| """ | ||
| with open(filename, 'r', encoding='utf-8') as f: | ||
| return f.read() | ||
|
|
||
|
|
||
| def write_file(filename: str, contents: str) -> None: | ||
| """ | ||
| Write the file's contents. | ||
| """ | ||
| with open(filename, 'w', encoding='utf-8') as f: | ||
| f.write(contents) | ||
|
|
||
|
|
||
| def main(): | ||
| """ | ||
| Patches go.mod. | ||
| """ | ||
| filename = 'go.mod' | ||
| _, go_versions, __ = split_go_mod( | ||
| get_file_contents_from_git_revision(filename, 'HEAD') | ||
| ) | ||
| head, _, tail = split_go_mod(read_file(filename)) | ||
| lines = head + go_versions + tail | ||
| write_file(filename, ''.join(lines)) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.