/// <summary>
        /// Creates a branch.
        /// </summary>
        /// <param name="action"></param>
        public void CreateBranch(object action)
        {
            var dialog = new PromptDialog
            {
                Title = "Creating a new branch",
                Message = "Please give a name for your new branch:"
            };

            dialog.ShowDialog();

            if (dialog.DialogResult == true)
            {
                using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
                {
                    var sha = repo.Head.Tip.Sha.ToString();
                    repo.Branches.Create(dialog.ResponseText, repo.Head.Tip.Sha.ToString());
                }

                LoadEntireRepository();
            }
        }
        /// <summary>
        /// Creates a tag.
        /// </summary>
        /// <param name="action"></param>
        public void CreateTag(object action)
        {
            var dialog = new PromptDialog();
            dialog.Title = "Create a new tag";
            dialog.Message = "Enter the name for the tag:";

            dialog.ShowDialog();

            if (dialog.DialogResult == true)
            {
                Commit commit = action as Commit;

                using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
                {
                    repo.Tags.Create(dialog.ResponseText, commit.Hash);
                    LoadEntireRepository();
                }
            }
        }
        /// <summary>
        /// Adds a new note for the given commit.
        /// </summary>
        /// <param name="action"></param>
        public void AddNote(object action)
        {
            var dialog = new PromptDialog();
            dialog.Title = "Add a note";
            dialog.Message = "Enter the note to add for the commit:";

            dialog.ShowDialog();

            if (dialog.DialogResult == true)
            {
                Commit commit = action as Commit;

                using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
                {
                    //repo.Notes.Create(commit.Hash, dialog.ResponseText);
                    LoadEntireRepository();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Creates a tag.
        /// </summary>
        /// <param name="action"></param>
        public void CreateTag(object action)
        {
            var commit = action as Commit;

            var dialog = new PromptDialog
            {
                Title = "Create a new tag",
                Message = "Enter the name for the tag:"
            };

            dialog.ShowDialog();

            if (dialog.DialogResult != true || commit == null)
                return;

            var response = dialog.ResponseText;

            Task.Run(() =>
            {
                using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
                {
                    repo.Tags.Create(response, commit.Hash);
                    LoadEntireRepository();
                }
            });
        }
Example #5
0
        /// <summary>
        /// Creates a branch.
        /// </summary>
        /// <param name="action"></param>
        public void CreateBranch(object action)
        {
            var dialog = new PromptDialog
            {
                Title = "Creating a new branch",
                Message = "Please give a name for your new branch:"
            };

            dialog.ShowDialog();

            if (dialog.DialogResult != true)
                return;

            var response = dialog.ResponseText;

            Task.Run(() =>
            {
                using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
                {
                    repo.Branches.Create(response, repo.Head.Tip.Sha.ToString(CultureInfo.InvariantCulture));
                }

                LoadEntireRepository();
            });
        }
Example #6
0
        /// <summary>
        /// Adds a new note for the given commit.
        /// </summary>
        /// <param name="action"></param>
        public void AddNote(object action)
        {
            var dialog = new PromptDialog
            {
                Title = "Add a note",
                Message = "Enter the note to add for the commit:"
            };

            dialog.ShowDialog();

            if (dialog.DialogResult != true)
                return;

            var commit = action as Commit;
            var response = dialog.ResponseText;

            Task.Run(() =>
            {
                using (var repo = new LibGit2Sharp.Repository(RepositoryFullPath))
                {
                    //repo.Notes.Create(commit.Hash, dialog.ResponseText); // TODO: Complete?
                    LoadEntireRepository();
                }
            });
        }
Example #7
0
        /// <summary>
        /// A helper method for opening a new repository for the given path.
        /// 
        /// This will bring up a question regarding the name to use and initialize the repository view model and load it up in the tab control.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private bool OpenNewRepository(string path)
        {
            var repository = new RepositoryViewModel
            {
                NotOpened = false,
                RepositoryFullPath = path
            };

            // Try loading the repository information and see if it worked.
            var result = repository.Init();
            if (result)
            {
                var mainWindowViewModel = (MainWindowViewModel) Application.Current.MainWindow.DataContext;

                // Ask the user for the Name.
                var nameDialog = new PromptDialog
                {
                    ResponseText = repository.RepositoryFullPath.Split(System.IO.Path.DirectorySeparatorChar).Last(),
                    Message = "Give a name for this repository:",
                    Title = "Information needed"
                };

                repository.Name = nameDialog.ShowDialog() == true ? nameDialog.ResponseText : repository.RepositoryFullPath;

                // Open the repository and display it visually.
                mainWindowViewModel.RepositoryViewModels.Add(repository);
                mainWindowViewModel.RecentRepositories.Add(repository);

                repository.SetThisRepositoryAsTheActiveTab();
            }
            else
            {
                return false;
            }

            return true;
        }