mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-01 04:36:13 +01:00
Warn about ignoring XDG_CONFIG_HOME and ~/.config/osc/oscrc if ~/.oscrc exists
This commit is contained in:
parent
8e7f8fd415
commit
8fc1ad5220
13
osc/conf.py
13
osc/conf.py
@ -65,6 +65,7 @@ from urllib.parse import urlsplit
|
|||||||
from . import credentials
|
from . import credentials
|
||||||
from . import OscConfigParser
|
from . import OscConfigParser
|
||||||
from . import oscerr
|
from . import oscerr
|
||||||
|
from .output import tty
|
||||||
from .util import xdg
|
from .util import xdg
|
||||||
from .util.helper import raw_input
|
from .util.helper import raw_input
|
||||||
from .util.models import *
|
from .util.models import *
|
||||||
@ -2056,11 +2057,17 @@ def identify_conf():
|
|||||||
if 'OSC_CONFIG' in os.environ:
|
if 'OSC_CONFIG' in os.environ:
|
||||||
return os.environ.get('OSC_CONFIG')
|
return os.environ.get('OSC_CONFIG')
|
||||||
|
|
||||||
if os.path.exists(os.path.expanduser('~/.oscrc')):
|
|
||||||
return '~/.oscrc'
|
|
||||||
|
|
||||||
conffile = os.path.join(xdg.XDG_CONFIG_HOME, "osc", "oscrc")
|
conffile = os.path.join(xdg.XDG_CONFIG_HOME, "osc", "oscrc")
|
||||||
|
|
||||||
|
if os.path.exists(os.path.expanduser("~/.oscrc")) or os.path.islink(os.path.expanduser("~/.oscrc")):
|
||||||
|
if "XDG_CONFIG_HOME" in os.environ:
|
||||||
|
print(f"{tty.colorize('WARNING', 'yellow,bold')}: Ignoring XDG_CONFIG_HOME env, loading an existing config from '~/.oscrc' instead", file=sys.stderr)
|
||||||
|
print(" To fix this, move the existing '~/.oscrc' to XDG location such as '~/.config/osc/oscrc'", file=sys.stderr)
|
||||||
|
elif os.path.exists(os.path.expanduser(conffile)):
|
||||||
|
print(f"{tty.colorize('WARNING', 'yellow,bold')}: Ignoring config '{conffile}' in XDG location, loading an existing config from ~/.oscrc instead", file=sys.stderr)
|
||||||
|
print(" To fix this, remove '~/.oscrc'", file=sys.stderr)
|
||||||
|
return '~/.oscrc'
|
||||||
|
|
||||||
return conffile
|
return conffile
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user