Exemplo n.º 1
0
        public static bool HasValue(string repositoryPath, string name)
        {
            if (repositoryPath == null)
            {
                throw new ArgumentNullException(nameof(repositoryPath));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            var configCommand = new GitCommand(repositoryPath, "config")
            {
                new GitCommandItem("get"),
                name,
            };

            return(configCommand.TryRun());
        }
Exemplo n.º 2
0
        public void InitializeRepository(string basePath, string repositoryPath, params LogPropertyInfo[] properties)
        {
            var cloneCommand = new GitCommand(null, "clone")
            {
                (GitPath)repositoryPath,
                (GitPath)basePath,
            };

            if (cloneCommand.TryRun() == true)
            {
                var fetchCommand = new GitCommand(basePath, "fetch")
                {
                    "origin",
                    "refs/notes/commits:refs/notes/commits",
                };
                fetchCommand.Run();
                GitConfig.SetValue(basePath, "receive.denyCurrentBranch", "ignore");
                return;
            }

            var initCommand = new GitCommand(null, "init")
            {
                (GitPath)basePath
            };

            initCommand.Run();

            var configCommand = new GitCommand(basePath, "config")
            {
                "receive.denyCurrentBranch",
                "ignore"
            };

            configCommand.Run();

            DirectoryUtility.Copy(repositoryPath, basePath);
            foreach (var item in GetEmptyDirectories(basePath))
            {
                File.WriteAllText(Path.Combine(item, KeepExtension), string.Empty);
            }

            var query = from item in DirectoryUtility.GetAllFiles(basePath, "*", true)
                        select(GitPath) PathUtility.GetFullPath(item);
            var itemList = query.ToList();

            var addCommand = new GitAddCommand(basePath, query.ToArray());

            addCommand.Run();

            var commitCommand = new GitCommitCommand(basePath, Environment.UserName, "first commit");

            commitCommand.Run();

            var props           = properties.Select(item => (GitPropertyValue)item).ToArray();
            var propText        = propertySerializer.Serialize(props);
            var addNotesCommand = new GitCommand(basePath, "notes")
            {
                "add",
                GitCommandItem.FromMessage(propText)
            };

            addNotesCommand.Run();

            this.SetID(basePath, "master", Guid.NewGuid());
        }