Esempio n. 1
0
        internal void UndoFileChanges(string fileName)
        {
            GitFileStatus status = GetFileStatus(fileName);

            if (status == GitFileStatus.Modified || status == GitFileStatus.Staged ||
                status == GitFileStatus.Deleted || status == GitFileStatus.Removed)
            {
                var deleteMsg = "";
                if (status == GitFileStatus.Deleted || status == GitFileStatus.Removed)
                {
                    deleteMsg = @"

Note: you will need to click 'Show All Files' in solution explorer to see the file.";
                }

                if (MessageBox.Show("Are you sure you want to undo changes for " + Path.GetFileName(fileName) +
                                    " and restore a version from the last commit? " + deleteMsg,
                                    "Undo Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    //SaveFileFromRepository(fileName, fileName);
                    //if (status == GitFileStatus.Staged || status == GitFileStatus.Removed)
                    //{
                    //    CurrentTracker.UnStageFile(fileName);
                    //}

                    CurrentTracker.CheckOutFile(fileName);
                }
            }
        }
 private void menuIgnoreFileExt_Click(object sender, RoutedEventArgs e)
 {
     GetSelectedFileName((fileName) =>
     {
         CurrentTracker.AddIgnoreItem("*" + Path.GetExtension(fileName));
     }, true);
 }
 private void menuIgnoreFile_Click(object sender, RoutedEventArgs e)
 {
     GetSelectedFileName((fileName) =>
     {
         CurrentTracker.AddIgnoreItem(fileName);
     }, true);
 }
 private void menuIgnoreFilePath_Click(object sender, RoutedEventArgs e)
 {
     GetSelectedFileName((fileName) =>
     {
         CurrentTracker.AddIgnoreItem(Path.GetDirectoryName(fileName) + "*/");
     }, true);
 }
Esempio n. 5
0
        private bool StageSelectedFiles(bool showWarning)
        {
            var unstaged = this.listView1.Items.Cast <GitFile>()
                           .Where(item => item.IsSelected && !item.IsStaged)
                           .ToList();
            var count = unstaged.Count;
            int i     = 0;

            foreach (var item in unstaged)
            {
                CurrentTracker.StageFile(item.FilePath);
                ShowStatusMessage(string.Format("Staged ({0}/{1}): {2}", i++, count, item.FileName));
            }

            CurrentTracker.Refresh();

            bool hasStaged = CurrentTracker == null ? false :
                             CurrentTracker.ChangedFiles.Any(f => f.IsStaged);

            if (!hasStaged && showWarning)
            {
                MessageBox.Show("No file has been staged for commit.", "Commit",
                                MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            return(hasStaged);
        }
Esempio n. 6
0
        internal void Commit()
        {
            //using (service.DisableRefresh())
            //{
            if (HasComments() && StageSelectedFiles(true))
            {
                string errorMessage = null;
                try
                {
                    ShowStatusMessage("Committing ...");
                    var id = CurrentTracker.Commit(Comments, false, chkSignOff.IsChecked == true);
                    if (!string.IsNullOrWhiteSpace(id))
                    {
                        ClearUI();
                    }
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                }

                if (!String.IsNullOrEmpty(errorMessage))
                {
                    MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
            // }

            //service.MarkDirty(false);
        }
Esempio n. 7
0
 public sealed override void Stop()
 {
     if (TrackerIsValid)
     {
         CurrentTracker.Stop();
     }
 }
Esempio n. 8
0
 public sealed override void Resume()
 {
     if (TrackerIsValid && CurrentTracker.IsPaused)
     {
         CurrentTracker.Resume();
     }
 }
Esempio n. 9
0
 public sealed override void Pause()
 {
     if (TrackerIsValid)
     {
         CurrentTracker.Pause();
     }
 }
 private void menuUnstage_Click(object sender, RoutedEventArgs e)
 {
     GetSelectedFileFullName(fileName =>
     {
         CurrentTracker.UnStageFile(fileName);
         ShowStatusMessage("Un-staged file: " + fileName);
     }, false);
 }
Esempio n. 11
0
        internal void CompareFile(string fileName)
        {
            GitFileStatus status = GetFileStatus(fileName);

            if (status == GitFileStatus.Modified || status == GitFileStatus.Staged)
            {
                string tempFile = Path.GetFileName(fileName);
                tempFile = Path.Combine(Path.GetTempPath(), tempFile);
                CurrentTracker.SaveFileFromRepository(fileName, tempFile);
                _sccProvider.RunDiffCommand(tempFile, fileName);
            }
        }
        internal async Task AmendCommit()
        {
            const string amendMsg = @"You are about to amend a commit that has tags or remotes, which could cause issues in local and remote repositories.

Are you sure you want to continue?";

            if (string.IsNullOrWhiteSpace(Comments))
            {
                Comments = CurrentTracker.LastCommitMessage;
                return;
            }
            else
            {
                if (CurrentTracker.CurrentCommitHasRefs() && MessageBox.Show(amendMsg, "Amend Last Commit",
                                                                             MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
                {
                    return;
                }

                var dte = BasicSccProvider.GetServiceEx <EnvDTE.DTE>();
                if (dte.ItemOperations.PromptToSave == EnvDTE.vsPromptResult.vsPromptResultCancelled)
                {
                    return;
                }

                StageSelectedFiles();

                try
                {
                    ShowStatusMessage("Amending last Commit ...");
                    var commitResult = await GitCommandWrappers.AmendCommit(CurrentTracker, Comments, chkSignOff.IsChecked == true);

                    if (commitResult.Succeeded)
                    {
                        ClearUI();
                        ShowStatusMessage("Amend last commit successfully. Commit Hash: " + commitResult.Item);
                    }
                    else
                    {
                        MessageBox.Show(commitResult.ErrorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                    ShowStatusMessage(ex.Message);
                }
            }
        }
        private void StageSelectedFiles()
        {
            var unstaged = this.listView1.Items.Cast <GitFile>()
                           .Where(item => item.IsSelected && !item.IsStaged)
                           .ToList();
            var count = unstaged.Count;
            int i     = 0;

            foreach (var item in unstaged)
            {
                CurrentTracker.StageFile(item.FilePath);
                ShowStatusMessage(string.Format("Staged ({0}/{1}): {2}", i++, count, item.FileName));
            }

            CurrentTracker.Refresh();
        }
Esempio n. 14
0
        /// <summary>
        /// Performs pattern matching
        /// </summary>
        /// <param name="ShortCircuit">Indicates to return as soon as a match is found</param>
        /// <returns>if short circuit 1 for match 0 for no matches , if not short circuit will return the number of matches found</returns>
        protected (ChronExMatches, int) PerformMatch(bool ShortCircuit, bool Store, ChronExMatchOptions options)
        {
            var debugTrackers = new List <Tracker>();
            // get the first element this is the lowest level filter to launching a tracker
            var getlemes = tree.Statements;

            if (!getlemes.Any())
            {
                return(null, 0);
            }
            var            firstElem      = getlemes.First();
            List <Tracker> FoundTrackers  = new List <Tracker>();
            Tracker        CurrentTracker = null;
            var            eventenum      = new EventStream(EventList);

            eventenum.MoveNext();
            while (eventenum.Current != null)
            {
                //if we don't have a tracker yet then determine if this event will possible start one
                if (CurrentTracker == null)
                {
                    if (firstElem.IsPotentialMatch(eventenum.Current))
                    {
                        CurrentTracker = new Tracker(tree);
                    }
                    else
                    {
                        //useually the tracker and the elemtn would move the line forward
                        //but since there is not tracker and there is no potential match
                        //the runner needs to move it forward
                        eventenum.MoveNext();
                        continue;
                    }
                }
                //We expect a process to move at least one event
                //to ensure we don't get stuck in a forwarding loop on a wildcard compare
                //so save the current loop item index and comapare afterwars
                var currentEventIndex = eventenum.ConcreatedIndex;
                var res = CurrentTracker.ProcessEvents(eventenum);
                if (res.Is_Match() && CurrentTracker.StoredList != null)
                {
                    FoundTrackers.Add(CurrentTracker);
                }
                //else
                //{
                //    //we need to manually move the  the event
                //    eventenum.MoveNext();
                //}
                if (CurrentTracker != null)
                {
                    debugTrackers.Add(CurrentTracker);
                }
                CurrentTracker = null;
                if (eventenum.ConcreatedIndex == currentEventIndex)
                {
                    eventenum.MoveNext();
                }
            }

            var lex = new ChronExMatches();

            foreach (var item in FoundTrackers)
            {
                var cmatch = new ChronExMatch();
                cmatch.CapturedEvents = item.StoredList;
                lex.Add(cmatch);
            }
            lex.DebugTrackers = debugTrackers;
            return(lex, lex.Count);
        }