Exemplo n.º 1
0
        public void StashWontPopIfConflictedOnUnStagedFile()
        {
            File.WriteAllText(@"testgit\file1", "This is a test");

            GitStashWrapper git     = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T);
            GitStashOptions options = new GitStashOptions {
                Untracked = true
            };

            options.Message = "Testing";
            IGitStashResults results = git.SaveStash(options);

            Assert.IsTrue(results.Success);
            Assert.IsTrue(git.Stashes.Count == 1);
            Assert.IsFalse(File.Exists("file1"));

            using (StreamWriter sw = File.AppendText(@"testgit\file1"))
            {
                sw.WriteLine("This is another test");
            }

            results = git.PopStash(new GitStashOptions(), 0);
            Assert.IsFalse(results.Success);
            Assert.IsTrue(git.Stashes.Count == 1);
            string txt = File.ReadAllText(@"testgit\file1");

            Assert.IsTrue(txt == "Commit this!This is another test\r\n");
        }
Exemplo n.º 2
0
        private void OnClickApplyStash()
        {
            IGitStashResults results = wrapper.ApplyStash(new GitStashOptions(), Stash.Index);

            if (!string.IsNullOrEmpty(results.Message))
            {
                page.ShowNotification(results.Message, NotificationType.Information);
            }
        }
Exemplo n.º 3
0
        public void Bug_57_CreateStashWithNewUntrackedChangeDoesntThrowException()
        {
            FileStream fs = File.Create(@"testgit\file2");

            fs.Close();
            GitStashWrapper git     = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T);
            GitStashOptions options = new GitStashOptions {
                Untracked = false, All = false, Ignored = false, Index = false, KeepIndex = false, Message = "bug_57"
            };

            IGitStashResults results = git.SaveStash(options);

            Assert.IsFalse(results.Success);
            Assert.IsTrue(git.Stashes.Count == 0);
            Assert.IsTrue(File.Exists(@"testgit\file2"));
        }
Exemplo n.º 4
0
        public void TestStash()
        {
            FileStream fs = File.Create(@"testgit\file2");

            fs.Close();
            GitStashWrapper         git     = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T);
            IEnumerable <IGitStash> stashes = git.Stashes;
            GitStashOptions         options = new GitStashOptions {
                Untracked = true
            };

            options.Message = "Testing";
            IGitStashResults results = git.SaveStash(options);

            Assert.IsFalse(File.Exists("file2"));
            Assert.IsTrue(results.Success);
            Assert.IsTrue(git.Stashes.Count == 1);
        }
        private void OnClickCreateStashButton()
        {
            IGitStashSaveOptions options = new GitStashOptions {
                All = StashAll, Ignored = StashIgnored, KeepIndex = StashKeepIndex, Untracked = StashUntracked, Message = NewStashMessage
            };
            IGitStashResults results = wrapper.SaveStash(options);

            if (!string.IsNullOrEmpty(results.Message))
            {
                page.ShowNotification(results.Message, NotificationType.Information);
            }
            if (results.Success)
            {
                NewStashMessage = "";
                OnPropertyChanged("Stashes");
                OnPropertyChanged("NewStashMessage");
                OnPropertyChanged("CreateStashButtonCommand");
            }
            else
            {
            }
        }
Exemplo n.º 6
0
        public void TestDeletethrowsExceptionWithInvalidIndex()
        {
            FileStream fs = File.Create(@"testgit\file2");

            fs.Close();
            GitStashWrapper git     = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T);
            GitStashOptions options = new GitStashOptions {
                Untracked = true
            };

            options.Message = "Testing";
            IGitStashResults results = git.SaveStash(options);

            Assert.IsTrue(results.Success);
            Assert.IsTrue(git.Stashes.Count == 1);
            Assert.IsFalse(File.Exists("file2"));

            results = git.DropStash(new GitStashOptions(), 2);
            Assert.IsFalse(results.Success);
            Assert.IsTrue(git.Stashes.Count == 1);
            Assert.IsFalse(File.Exists(@"testgit\file2"));
        }
Exemplo n.º 7
0
        public void TestStashesReturnsTheProperIndex()
        {
            FileStream fs = File.Create(@"testgit\file2");

            fs.Close();

            GitStashWrapper git     = new GitStashWrapper("testgit", GetEventService(), GetLogger(), GetProjects(), T);
            GitStashOptions options = new GitStashOptions {
                Untracked = true
            };

            options.Message = "one";
            IGitStashResults results = git.SaveStash(options);

            Assert.IsTrue(results.Success);
            Assert.IsTrue(git.Stashes.Count == 1);
            Assert.IsFalse(File.Exists("file2"));

            fs = File.Create(@"testgit\file2");
            fs.Close();

            options.Message = "two";
            results         = git.SaveStash(options);

            Assert.IsTrue(results.Success);
            Assert.IsTrue(git.Stashes.Count == 2);
            Assert.IsFalse(File.Exists("file2"));

            IGitStash recent = git.Stashes[0];
            IGitStash older  = git.Stashes[1];

            Assert.IsTrue(recent.Index == 0);
            Assert.IsTrue(recent.Message == "two");

            Assert.IsTrue(older.Index == 1);
            Assert.IsTrue(older.Message == "one");
        }