Пример #1
0
 /// <summary>
 ///     git add *
 /// </summary>
 /// <param name="hubimusMaximus">the github repo we're working with</param>
 public static void StageAll(Github hubimusMaximus)
 {
     foreach (var file in hubimusMaximus.Status())
     {
         hubimusMaximus.Add(file.Key, file.Value);
     }
 }
Пример #2
0
        /// <summary>
        ///     On sync we have 2 options.
        ///     A) The user doesn't even have a copy of the repo.
        ///         -- In which case we clone it for them.
        ///     B) The user has a local copy.
        ///         -- In which case we get latest changes, then push any changes the user has.
        /// 
        ///     Then a reload of the tests/testplans.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="MouseButtonEventArgs"/> instance containing the event data.</param>
        private void Sync_Click(object sender, MouseButtonEventArgs e)
        {
            if (cbProjects.SelectedItem == null)
            {
                MessageBox.Show("Please select a project to sync.");
                return;
            }

            lblSync.Visibility = Visibility.Visible;

            var gh = new Github((RepositoryInfo)cbProjects.SelectedItem);
            if (IOHelper.LocalDirectoryExists(string.Format("Projects\\{0}", ((RepositoryInfo)cbProjects.SelectedItem).Name)))
            {
                var credentials = GitHelper.GetGitCredentials();
                while (credentials == null || string.IsNullOrWhiteSpace(credentials.Password) || string.IsNullOrWhiteSpace(credentials.Username))
                {
                    credentials = GitHelper.GetGitCredentials();
                }

                gh.Pull(credentials);
                if (gh.Status().Count != 0)
                {
                    GitHelper.StageAll(gh);
                    if (gh.Status().Any(t => t.Value != FileStatus.Staged))
                        gh.Commit();
                    var result = gh.Push(credentials);

                    if (result != string.Empty)
                    {
                        MessageBox.Show(result);
                    }
                }
            }
            else
            {
                IOHelper.CreateLocalDirectoryIfNotExists(string.Format("Projects\\{0}", ((RepositoryInfo)cbProjects.SelectedItem).Name));
                gh.CloneRepository();
            }

            LoadTests();
            LoadTestPlans();
            lblSync.Visibility = Visibility.Hidden;
        }