예제 #1
0
 public IEnumerable <string> TrackedFiles()
 {
     return(_gitProcess
            .Execute("ls-files", false)
            .Stdout
            .Select(f => SanePath.Combine(RepoPath, f)));
 }
예제 #2
0
        public void HistoryWalker_should_rename_and_edit()
        {
            var result = GitProcess.Execute("ls-files", false);

            Assert.That(result.Stdout.Contains("AliceB2.txt"), Is.True);
            Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceB2.txt")), Is.EqualTo(_aliceBContent + "xxx"));
        }
예제 #3
0
        public void HistoryWalker_should_exclude_files_matching_regex_patterns()
        {
            HistoryWalker.Walk(new EntryPoint(1));

            var result = GitProcess.Execute("rev-list --all --count");

            Assert.That(result.Stderr.Count(), Is.EqualTo(0));
            Assert.That(result.Stdout.Count(), Is.EqualTo(1));
            Assert.That(result.Stdout.Contains("1"));
            Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceA.txt")), Is.EqualTo("Alice A1"));
        }
예제 #4
0
        public void HistoryWalker_should_edit_files()
        {
            HistoryWalker.Walk(new EntryPoint(1));

            File.WriteAllText(SanePath.Combine(RepoPath, "AliceA.txt"), "xxx");

            GitProcess.Execute("checkout -- .", false);

            Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceA.txt")), Is.EqualTo("Alice A2"));
            Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceB.txt")), Is.EqualTo("Alice B2"));
            Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "AliceC.txt")), Is.EqualTo("Alice C2"));
        }
예제 #5
0
        protected override void OneTimeSetUp()
        {
            base.OneTimeSetUp();

            Env
            .Branch("master", "$/Mock/A", SanePath.Combine(RepoPath, "A"))
            .Branch("master", "$/Mock/B", SanePath.Combine(RepoPath, "B"))
            .Changeset(OldUserAlice, UserAlice, "Add files")
            .Add("$/Mock/A/AliceA.txt", "Alice A")
            .Add("$/Mock/B/AliceB.txt", "Alice B")
            .End();
        }
예제 #6
0
        protected override void OneTimeSetUp()
        {
            base.OneTimeSetUp();

            var aliceBContent = GenerateRandomString(200);

            Env
            .Branch("master", "$/Mock/Main/X", SanePath.Combine(RepoPath, "X"))
            .Branch("feature-branch", "$/Mock/Feature/X", SanePath.Combine(RepoPath, "X"))
            .Branch("feature-branch", "$/Mock/Feature/Y", SanePath.Combine(RepoPath, "Y"))

            // Alice creates files on branch 'master'
            .Changeset(OldUserAlice, UserAlice, "Add files")
            .Add("$/Mock/Main/X/SubFolderA/AliceA.txt", "Alice A")
            .Add("$/Mock/Main/X/AliceB1.txt", aliceBContent)
            .Add("$/Mock/Main/X/AliceC.txt", "Alice C")

            // Bob creates/deletes/edits files on branch 'feature-branch'
            .Changeset(OldUserBob, UserBob, "Edit files")
            .Hierarchy("$/Mock/Main/X/", "$/Mock/Feature/X/")
            .Add("$/Mock/Feature/X/BobA.txt", "Bob A")
            .Add("$/Mock/Feature/X/BobB.txt", "Should be undone in the merge by the changes from the Tfs")
            .Edit("$/Mock/Feature/X/SubFolderA/AliceA.txt", "Alice A, Bob A")
            .Delete("$/Mock/Feature/X/AliceB1.txt", ItemType.File, ChangeType.Delete | ChangeType.SourceRename)
            .Rename("$/Mock/Feature/X/AliceB1.txt", "$/Mock/Feature/X/AliceB2.txt", aliceBContent + "xxx", ItemType.File, ChangeType.Rename | ChangeType.Edit)
            .Delete("$/Mock/Feature/X/AliceC.txt")
            .Add("$/Mock/Feature/Y/BobC.txt", "Bob C")

            .End();

            HistoryWalker.Walk(new EntryPoint(1));

            Env
            // Alice merges 'feature-branch' into 'master'
            .Changeset(OldUserAlice, UserAlice, "Merge feature-branch")
            .File(SanePath.Combine(RepoPath, "Y/AlienB.txt"), "Alien file that does not belong to the changeset")
            .Add("$/Mock/Main/X/BobA.txt", "Bob A", ItemType.File, ChangeType.Merge | ChangeType.Branch)
            .Edit("$/Mock/Main/X/SubFolderA/AliceA.txt", "Alice A", ItemType.File, ChangeType.Merge | ChangeType.Edit)
            .Merge("$/Mock/Feature/X/SubFolderA/AliceA.txt")
            .Delete("$/Mock/Main/X/AliceB1.txt", ItemType.File, ChangeType.Merge | ChangeType.Delete | ChangeType.SourceRename)
            .Rename("$/Mock/Main/X/AliceB1.txt", "$/Mock/Main/X/AliceB2.txt", aliceBContent + "xxx", ItemType.File, ChangeType.Merge | ChangeType.Rename | ChangeType.Edit)
            .Delete("$/Mock/Main/X/AliceC.txt", ItemType.File, ChangeType.Merge | ChangeType.Delete)

            .End();

            HistoryWalker.Walk(new EntryPoint(3));
        }
예제 #7
0
파일: Delta.cs 프로젝트: monounity/GetGit
        private void FindDeletes()
        {
            Log.Info("Looking for files to delete...");

            var localPaths   = GetLocalPaths();
            var gitDirectory = SanePath.Combine(_git.RepoPath, ".git").ToLower();

            foreach (var file in Directory.GetFiles(_branch.Mapping.Path, "*.*", SearchOption.AllDirectories))
            {
                var exactLocalPath = SanePath.Normalize(file);
                var lowerLocalPath = exactLocalPath.ToLower();

                if (!localPaths.Keys.Contains(lowerLocalPath) && !_renames.ContainsKey(lowerLocalPath) && !lowerLocalPath.Contains(gitDirectory))
                {
                    _deletes.Add(exactLocalPath);
                }
            }
        }
예제 #8
0
        public IEnumerable <IChangeset> GetHistory(EntryPoint entryPoint)
        {
            Log.Info("Querying changesets for " + entryPoint);

            var history = _versionControlServer.QueryHistory(
                SanePath.Combine(_teamProject.ServerItem, entryPoint.Path),
                tfs.VersionSpec.Latest,
                0,            // no deletionId
                tfs.RecursionType.Full,
                null,         // any user
                entryPoint.VersionFrom.Spec(),
                entryPoint.VersionTo.Spec(),
                int.MaxValue, // number of items to return
                false,        // don't include individual item changes
                false,        // no slotMode
                false,        // don't include download info
                true          // true: sort ascending, first changeset first
                );

            return(history
                   .Cast <tfs.Changeset>()
                   .Select(c => new Changeset(c)));
        }
예제 #9
0
 public string SanePath_should_normalize_path(string path)
 {
     return(SanePath.Normalize(path));
 }
예제 #10
0
 public string SanePath_should_combine_paths(params string[] paths)
 {
     return(SanePath.Combine(paths));
 }
예제 #11
0
 public static void CopyFilesTo(string path)
 {
     File.Copy(SanePath.Combine(Env.ExecutingDirectory(), "gitignore-template.txt"), SanePath.Combine(path, ".gitignore"));
     File.Copy(SanePath.Combine(Env.ExecutingDirectory(), "gitattributes-template.txt"), SanePath.Combine(path, ".gitattributes"));
 }
예제 #12
0
        public static string ExecutingDirectory()
        {
            var executablePath = System.Reflection.Assembly.GetExecutingAssembly().Location;

            return(SanePath.Normalize(Path.GetDirectoryName(executablePath)));
        }
예제 #13
0
 public void HistoryWalker_should_delete_files_that_doesnt_belong_to_the_changeset()
 {
     Assert.That(!File.Exists(SanePath.Combine(RepoPath, "Y/AlienB.txt")));
     Assert.That(!File.Exists(SanePath.Combine(RepoPath, "Y/BobC.txt")));
 }
예제 #14
0
 public void HistoryWalker_should_undo_staged_edits_during_merge_and_use_the_content_from_Tfs()
 {
     Assert.That(File.ReadAllText(SanePath.Combine(RepoPath, "X/SubFolderA/AliceA.txt")), Is.EqualTo("Alice A"));
 }