Example #1
0
 private GitConfig(
     GitConfigFile configFile,
     GitConfig parent)
 {
     m_configFile = configFile;
     m_parent     = parent;
 }
Example #2
0
        public static GitConfig Load(GitConfigFile configFile, GitConfig parent = null)
        {
            if (configFile == null)
            {
                throw new ArgumentNullException(nameof(configFile));
            }

            return(new GitConfig(configFile, parent));
        }
Example #3
0
        public static GitConfig Load(string path = null, string configFileName = null)
        {
            // explicit config file
            if (path != null && !path.IsDir())
            {
                var dir = path.GetDir();
                if (string.Compare(Path.GetFileName(path), configFileName, ignoreCase: true) == 0)
                {
                    dir = dir.GetParentDir();
                }

                return(Load(
                           GitConfigFile.Load(path),
                           Load(dir, configFileName ?? Path.GetExtension(path))
                           ));
            }

            // path is directory
            var workingDir = path;

            if (workingDir == null)
            {
                workingDir = Environment.CurrentDirectory;
            }
            workingDir = workingDir.ToDir();

            // inherited config file
            var parentConfigFile = workingDir.FindFileAbove(configFileName);

            if (parentConfigFile != null)
            {
                return(Load(parentConfigFile, configFileName));
            }

            // local config file
            var localConfigFile = GitConfigFile.Load(workingDir);

            if (localConfigFile != null)
            {
                return(Load(GitConfigFile.Load(workingDir), LoadGlobal()));
            }

            // global config file
            return(LoadGlobal());
        }
Example #4
0
 internal GitConfigValue(GitConfigFile configFile, string key, string value)
 {
     m_configFile = configFile;
     m_keyValue   = new KeyValuePair <string, string>(key, value);
 }
Example #5
0
 public static GitConfig LoadGlobal() => Load(GitConfigFile.LoadGlobal(), LoadSystem());