-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add script to update token * docs(README): Update README
- Loading branch information
1 parent
b188646
commit 3064a16
Showing
3 changed files
with
31 additions
and
1 deletion.
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
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
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,22 @@ | ||
#!/usr/bin/env python | ||
|
||
import glob | ||
import argparse | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description='Replace tokens') | ||
parser.add_argument("--old-token", help="Old token", required=True) | ||
parser.add_argument("--new-token", help="New token", required=True) | ||
args = parser.parse_args() | ||
|
||
for path in glob.glob("/repositories/*/*.git/config", recursive=True): | ||
repo_name = path.replace("/repositories/", "").replace(".git/config", "") | ||
print(f"Updating: {repo_name}") | ||
|
||
with open(path, 'r', encoding="utf-8") as file: | ||
filedata = file.read() | ||
|
||
filedata = filedata.replace(f"{args.old_token}", f"{args.new_token}") | ||
|
||
with open(path, 'w', encoding="utf-8") as file: | ||
file.write(filedata) |