public void CreateRepository(string author, string basePath, string initPath, string comment, params LogPropertyInfo[] properties)
        {
            var baseUri         = new Uri(basePath);
            var repositoryPath  = baseUri.LocalPath;
            var repositoryName  = Path.GetFileName(initPath);
            var checkoutCommand = new GitCommand(repositoryPath, "checkout")
            {
                new GitCommandItem("orphan"), repositoryName
            };

            checkoutCommand.Run();
            var removeCommand = new GitCommand(repositoryPath, "rm")
            {
                "-rf", "."
            };

            removeCommand.Run();

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

            var statusItems = GitItemStatusInfo.Run(repositoryPath);
            var addCommand  = new GitCommand(repositoryPath, "add");

            foreach (var item in statusItems)
            {
                if (item.Status == RepositoryItemStatus.Untracked)
                {
                    addCommand.Add((GitPath)item.Path);
                }
            }
            addCommand.Run();

            var commitCommand = new GitCommitCommand(repositoryPath, author, comment);

            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(repositoryPath, repositoryName, Guid.NewGuid());
            this.SetDescription(repositoryPath, repositoryName, comment);
        }
示例#2
0
        public void Delete(string path)
        {
            var removeCommand = new GitCommand(this.BasePath, "rm")
            {
                (GitPath)path,
            };

            if (Directory.Exists(path) == true)
            {
                removeCommand.Add(new GitCommandItem('r'));
            }
            removeCommand.Run(this.logService);
        }
示例#3
0
        public void Add(string path)
        {
            var addCommand = new GitCommand(this.BasePath, "add");

            if (DirectoryUtility.IsDirectory(path) == true)
            {
                var keepPath = Path.Combine(path, GitRepositoryProvider.KeepExtension);
                if (File.Exists(keepPath) == false)
                {
                    File.WriteAllText(keepPath, string.Empty);
                    addCommand.Add((GitPath)keepPath);
                }
            }
            else
            {
                addCommand.Add((GitPath)path);
            }

            if (addCommand.Items.Any() == true)
            {
                addCommand.Run(this.logService);
            }
        }
示例#4
0
        public static               GitItemStatusInfo[] Run(string repositoryPath, params string[] paths)
        {
            var statusCommand = new GitCommand(repositoryPath, "status")
            {
                new GitCommandItem('s'),
                new GitCommandItem(string.Empty)
            };

            foreach (var item in paths)
            {
                statusCommand.Add((GitPath)item);
            }
            return(Parse(statusCommand.Run()));
        }