-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use git-autoshare with git-aggregator
TT32042
- Loading branch information
1 parent
7803131
commit 55c7933
Showing
9 changed files
with
149 additions
and
9 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
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
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,44 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
"""Generates the appropiate configuration file for git-autoshare according to | ||
user-defined settings through environment variables | ||
""" | ||
|
||
import os | ||
from pathlib import Path | ||
|
||
import yaml | ||
|
||
GIT_AUTOSHARE_ORGS_TO_CACHE = os.environ.get( | ||
"GIT_AUTOSHARE_ORGS_TO_CACHE", "OCA,odoo,Tecnativa" | ||
) | ||
GIT_AUTOSHARE_CONFIG_DIR = os.environ.get( | ||
"GIT_AUTOSHARE_CONFIG_DIR", "/home/odoo/.config/git-autoshare/" | ||
) | ||
GIT_AUTOSHARE_CACHE_DIR = os.environ.get( | ||
"GIT_AUTOSHARE_CACHE_DIR", "/home/odoo/.cache/git-autoshare/" | ||
) | ||
UID = int(os.environ["UID"]) | ||
GID = int(os.environ["GID"]) | ||
|
||
orgs_to_cache = GIT_AUTOSHARE_ORGS_TO_CACHE.split(",") | ||
git_autoshare_config_dir_path = Path(GIT_AUTOSHARE_CONFIG_DIR) | ||
git_autoshare_config_path = git_autoshare_config_dir_path / "repos.yml" | ||
|
||
if git_autoshare_config_path.is_file(): | ||
exit(0) | ||
else: | ||
git_autoshare_config_dir_path.mkdir(parents=True, exist_ok=True) | ||
os.chown(str(git_autoshare_config_dir_path), UID, GID) | ||
|
||
git_autoshare_config = {"github.com": {"*": {"orgs": orgs_to_cache,}}} | ||
|
||
with git_autoshare_config_path.open("w") as f: | ||
f.write(yaml.safe_dump(git_autoshare_config)) | ||
os.chown(str(git_autoshare_config_path), UID, GID) | ||
|
||
# Ensure cache dir exists and has correct permissions | ||
git_autoshare_cache_dir = Path(GIT_AUTOSHARE_CACHE_DIR) | ||
git_autoshare_cache_dir.mkdir(parents=True, exist_ok=True) | ||
os.chown(str(git_autoshare_cache_dir), UID, GID) |
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