diff --git a/docs/internal-fs-layout.md b/docs/internal-fs-layout.md index 8be61782..401ebda1 100644 --- a/docs/internal-fs-layout.md +++ b/docs/internal-fs-layout.md @@ -243,7 +243,9 @@ The `[branch]` settings are updated by `repo start` and `git branch`. ## ~/ dotconfig layout -Repo will create & maintain a few files in the user's home directory. +Repo will create & maintain a few files under the `.repoconfig/` directory. +This is placed in the user's home directory by default but can be changed by +setting `REPO_CONFIG_DIR`. * `.repoconfig/`: Repo's per-user directory for all random config files/state. * `.repoconfig/config`: Per-user settings using [git-config] file format. diff --git a/git_config.py b/git_config.py index 029beb4d..9ad979ad 100644 --- a/git_config.py +++ b/git_config.py @@ -69,8 +69,6 @@ def _key(name): class GitConfig(object): _ForUser = None - _USER_CONFIG = '~/.gitconfig' - _ForSystem = None _SYSTEM_CONFIG = '/etc/gitconfig' @@ -83,9 +81,13 @@ class GitConfig(object): @classmethod def ForUser(cls): if cls._ForUser is None: - cls._ForUser = cls(configfile=os.path.expanduser(cls._USER_CONFIG)) + cls._ForUser = cls(configfile=cls._getUserConfig()) return cls._ForUser + @staticmethod + def _getUserConfig(): + return os.path.expanduser('~/.gitconfig') + @classmethod def ForRepository(cls, gitdir, defaults=None): return cls(configfile=os.path.join(gitdir, 'config'), @@ -415,7 +417,10 @@ class GitConfig(object): class RepoConfig(GitConfig): """User settings for repo itself.""" - _USER_CONFIG = '~/.repoconfig/config' + @staticmethod + def _getUserConfig(): + repo_config_dir = os.getenv('REPO_CONFIG_DIR', os.path.expanduser('~')) + return os.path.join(repo_config_dir, '.repoconfig/config') class RefSpec(object): diff --git a/repo b/repo index 8030afbd..ce3df054 100755 --- a/repo +++ b/repo @@ -149,7 +149,7 @@ if not REPO_REV: BUG_URL = 'https://bugs.chromium.org/p/gerrit/issues/entry?template=Repo+tool+issue' # increment this whenever we make important changes to this script -VERSION = (2, 30) +VERSION = (2, 32) # increment this if the MAINTAINER_KEYS block is modified KEYRING_VERSION = (2, 3) @@ -265,7 +265,8 @@ else: urllib.error = urllib2 -home_dot_repo = os.path.expanduser('~/.repoconfig') +repo_config_dir = os.getenv('REPO_CONFIG_DIR', os.path.expanduser('~')) +home_dot_repo = os.path.join(repo_config_dir, '.repoconfig') gpg_dir = os.path.join(home_dot_repo, 'gnupg')