Пример #1
0
        public static               GitItemStatusInfo[] Parse(string text)
        {
            var matches  = Regex.Matches(text, nameStatusPattern, RegexOptions.Multiline);
            var itemList = new List <GitItemStatusInfo>(matches.Count);

            for (var i = 0; i < matches.Count; i++)
            {
                var match = matches[i];
                var x     = match.Groups["X"].Value;
                var y     = match.Groups["Y"].Value;
                var path1 = match.Groups["path1"].Value;
                var path2 = match.Groups["path2"].Value;

                var item = new GitItemStatusInfo()
                {
                    X       = x,
                    Y       = y,
                    Path    = path2 == string.Empty ? path1 : path2,
                    OldPath = path2 == string.Empty ? path1 : path1,
                };
                itemList.Add(item);
            }

            return(itemList.ToArray());
        }
Пример #2
0
        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);
        }
Пример #3
0
        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());
        }