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); }
public RepositoryItem[] Status(params string[] paths) { var items = GitItemStatusInfo.Run(this.BasePath, paths); var itemList = new List <RepositoryItem>(items.Length); foreach (var item in items) { var repositoryItem = new RepositoryItem() { Path = new Uri(UriUtility.Combine(this.BasePath, item.Path)).LocalPath, OldPath = new Uri(UriUtility.Combine(this.BasePath, item.OldPath)).LocalPath, Status = item.Status, }; itemList.Add(repositoryItem); } return(itemList.ToArray()); }