public void Reset(bool resetData)
 {
     if (resetData)
     {
         _orderRepository.Reset();
     }
 }
Exemple #2
0
        /// <summary>
        /// Sets the current <see cref="Repository.Head"/> to the specified commit and optionally resets the <see cref="Index"/> and
        /// the content of the working tree to match.
        /// </summary>
        /// <param name="repository">The <see cref="Repository"/> being worked with.</param>
        /// <param name="resetOptions">Flavor of reset operation to perform.</param>
        /// <param name="committish">A revparse spec for the target commit object.</param>
        public static void Reset(this IRepository repository, ResetOptions resetOptions, string committish = "HEAD")
        {
            Ensure.ArgumentNotNullOrEmptyString(committish, "committish");

            Commit commit = LookUpCommit(repository, committish);

            repository.Reset(resetOptions, commit);
        }
Exemple #3
0
        /// <summary>
        /// Reset and clean current working directory. This will ensure that the current
        /// working directory matches the current Head commit.
        /// </summary>
        /// <param name="repo">Repository whose current working directory should be operated on.</param>
        private void ResetAndCleanWorkingDirectory(IRepository repo)
        {
            // Reset the index and the working tree.
            repo.Reset(ResetMode.Hard);

            // Clean the working directory.
            repo.RemoveUntrackedFiles();
        }
        /// <summary>
        /// Sets the current <see cref="Repository.Head"/> to the specified commit and optionally resets the <see cref="Index"/> and
        /// the content of the working tree to match.
        /// </summary>
        /// <param name="repository">The <see cref="Repository"/> being worked with.</param>
        /// <param name="resetMode">Flavor of reset operation to perform.</param>
        /// <param name="committish">A revparse spec for the target commit object.</param>
        /// <param name="signature">Identification for use when updating the reflog</param>
        /// <param name="logMessage">Message to append to the reflog</param>
        public static void Reset(this IRepository repository, ResetMode resetMode, string committish = "HEAD",
                                 Signature signature = null, string logMessage = null)
        {
            Ensure.ArgumentNotNullOrEmptyString(committish, "committish");

            Commit commit = LookUpCommit(repository, committish);

            repository.Reset(resetMode, commit, signature, logMessage);
        }
Exemple #5
0
        /// <summary>
        /// Replaces entries in the <see cref="Index"/> with entries from the specified commit.
        /// </summary>
        /// <param name="repository">The <see cref="Repository"/> being worked with.</param>
        /// <param name="committish">A revparse spec for the target commit object.</param>
        /// <param name="paths">The list of paths (either files or directories) that should be considered.</param>
        /// <param name="explicitPathsOptions">
        /// If set, the passed <paramref name="paths"/> will be treated as explicit paths.
        /// Use these options to determine how unmatched explicit paths should be handled.
        /// </param>
        public static void Reset(this IRepository repository, string committish = "HEAD", IEnumerable <string> paths = null, ExplicitPathsOptions explicitPathsOptions = null)
        {
            if (repository.Info.IsBare)
            {
                throw new BareRepositoryException("Reset is not allowed in a bare repository");
            }

            Ensure.ArgumentNotNullOrEmptyString(committish, "committish");

            Commit commit = LookUpCommit(repository, committish);

            repository.Reset(commit, paths, explicitPathsOptions);
        }
 private static void AssertStage(bool?ignorecase, IRepository repo, string path)
 {
     try
     {
         repo.Index.Stage(path);
         Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(path));
         repo.Reset();
         Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(path));
     }
     catch (ArgumentException)
     {
         Assert.False(ignorecase ?? true);
     }
 }
Exemple #7
0
        public Task ExecuteAsync(object?parameter = null, CancellationToken cancellation = default)
        {
            if (view.SelectedEntry is CommitEntry selectedEntry)
            {
                var dialog = new ResetDialog(string.Format("Reset current branch {0} to {1}?", selectedEntry.Repository.Head.GetName(), selectedEntry.Commit.GetShortSha()));
                if (mainThread.Invoke(() => dialog.ShowDialog()) == true)
                {
                    repository.Reset(dialog.ResetMode, view.SelectedEntry.Commit);

                    view.Refresh();
                }
            }

            return(Task.CompletedTask);
        }
    public static Branch CreatePullRequest(this IRepository repository, string from, string to, int prNumber = 2, bool isRemotePr = true)
    {
        repository.Checkout(to);
        repository.MergeNoFF(from);
        repository.CreateBranch("pull/" + prNumber + "/merge").Checkout();
        repository.Checkout(to);
        repository.Reset(ResetMode.Hard, "HEAD~1");
        var pullBranch = repository.Checkout("pull/" + prNumber + "/merge");

        if (isRemotePr)
        {
            // If we delete the branch, it is effectively the same as remote PR
            repository.Branches.Remove(from);
        }

        return(pullBranch);
    }
Exemple #9
0
        public void Merge(string sourceBranch, string destinationBranch)
        {
            _repo.Checkout(_repo.Branches[destinationBranch]);

            var oldHeadCommit = _repo.Head.Tip;
            var signature     = GetSignature();
            var result        = _repo.Merge(_repo.Branches[sourceBranch], signature);

            switch (result.Status)
            {
            case MergeStatus.Conflicts:
                //abort the merge by resetting to the state prior to the merge
                _repo.Reset(ResetMode.Hard, oldHeadCommit);
                break;

            case MergeStatus.NonFastForward:
                //https://help.github.com/articles/dealing-with-non-fast-forward-errors/
                Pull();
                Merge(sourceBranch, destinationBranch);     //a little leary about this. Could stack overflow if I'm wrong.
                break;
            }

            Refresh();
        }
Exemple #10
0
 public IHttpActionResult ResetList()
 {
     repository.Reset();
     return(Ok());
 }
Exemple #11
0
        bool UpdateGit(IRepository repo)
        {
            var recompileNeeded = true;

            using (var _ = new ChangingOutput("Updating source code . . ."))
            {
                _.FinishLine();

                // Update origin URL and re-initialize repo
                var origin = repo.Network.Remotes["origin"];
                if (origin.Url != _gitClonePath)
                {
                    repo.Network.Remotes.Update(origin, r => r.Url = _gitClonePath);
                }

                using (var t = new ChangingOutput("Fetching updates from remote . . ."))
                {
                    repo.Fetch("origin", new FetchOptions()
                    {
                        OnTransferProgress = (x) =>
                        {
                            t.PrintProgress((double)x.ReceivedObjects / x.TotalObjects);
                            return(true);
                        }
                    });

                    t.PrintResult(true);
                }

                var         currentCommit = repo.Head.Tip;
                MergeResult result;
                try
                {
                    using (var t = new ChangingOutput("Merging in updates . . ."))
                    {
                        result = repo.Merge(repo.Branches["origin/master"], new Signature(Environment.UserName, "*****@*****.**", DateTime.Now),
                                            new MergeOptions
                        {
                            CommitOnSuccess      = true,
                            FileConflictStrategy = CheckoutFileConflictStrategy.Ours,
                            MergeFileFavor       = MergeFileFavor.Normal,
                            OnCheckoutProgress   = (n, processed, total) =>
                            {
                                t.PrintProgress((double)processed / total);
                            },
                        });

                        t.PrintResult(result.Status != MergeStatus.Conflicts);
                    }

                    if (result.Status == MergeStatus.UpToDate)
                    {
                        Console.WriteLine("Source was already up to date");
                        recompileNeeded = RestoreDeleteFiles(repo);
                        _.PrintResult(true);
                    }
                    else if (result.Status == MergeStatus.Conflicts)
                    {
                        throw new MergeConflictException();
                    }
                    else
                    {
                        Console.WriteLine("Updated to {0} : {1}", result.Commit.Sha.Substring(0, 10), result.Commit.MessageShort);
                        _.PrintResult(true);
                    }
                }
                catch (MergeConflictException)
                {
                    Console.WriteLine("Merge resulted in conflicts. This usually indictates a user-edited source");
                    Console.WriteLine("Your Aura will NOT be updated until you undo your changes to the files.");
                    Console.WriteLine("This is a bad thing, so fix it ASAP.");
                    Console.WriteLine("NOTE: If you're trying to make configuration changes, use the \"user\" folders instead.");
                    Console.WriteLine("Rolling back merge...");
                    repo.Reset(currentCommit);
                    recompileNeeded = false;
                    _.PrintResult(false);
                }

                return(recompileNeeded);
            }
        }
 /// <summary>
 /// Sets the current <see cref="Repository.Head"/> and resets the <see cref="Index"/> and
 /// the content of the working tree to match.
 /// </summary>
 /// <param name="repository">The <see cref="Repository"/> being worked with.</param>
 /// <param name="resetMode">Flavor of reset operation to perform.</param>
 public static void Reset(this IRepository repository, ResetMode resetMode)
 {
     repository.Reset(resetMode, "HEAD");
 }
 /// <summary>
 /// Replaces entries in the <see cref="Repository.Index"/> with entries from the specified commit.
 /// </summary>
 /// <param name="repository">The <see cref="IRepository"/> being worked with.</param>
 /// <param name="commit">The target commit object.</param>
 public static void Reset(this IRepository repository, Commit commit)
 {
     repository.Reset(commit, null, null);
 }
Exemple #14
0
 public void Reset(ResetMode resetMode, Commit commit)
 {
     repositoryInstance.Reset(resetMode, commit);
 }
Exemple #15
0
 public void Reset(ResetMode resetMode, Commit commit) =>
 repository.Reset(resetMode, commit);
        /// <summary>
        /// Reset and clean current working directory. This will ensure that the current
        /// working directory matches the current Head commit.
        /// </summary>
        /// <param name="repo">Repository whose current working directory should be operated on.</param>
        private void ResetAndCleanWorkingDirectory(IRepository repo)
        {
            // Reset the index and the working tree.
            repo.Reset(ResetMode.Hard);

            // Clean the working directory.
            repo.RemoveUntrackedFiles();
        }
Exemple #17
0
        bool UpdateGit(IRepository repo)
        {
            var recompileNeeded = true;
            using (var _ = new ChangingOutput("Updating source code . . ."))
            {
                _.FinishLine();

                using (var t = new ChangingOutput("Fetching updates from GitHub . . ."))
                {
                    repo.Fetch("origin", new FetchOptions()
                    {
                        OnTransferProgress = (x) =>
                        {
                            t.PrintProgress((double) x.ReceivedObjects/x.TotalObjects);
                            return true;
                        }
                    });

                    t.PrintResult(true);
                }

                var currentCommit = repo.Head.Tip;
                MergeResult result;
                try
                {
                    using (var t = new ChangingOutput("Merging in updates . . ."))
                    {
                        result = repo.Merge(repo.Head.TrackedBranch, new Signature(Environment.UserName, "*****@*****.**", DateTime.Now),
                            new MergeOptions
                            {
                                CommitOnSuccess = true,
                                FileConflictStrategy = CheckoutFileConflictStrategy.Ours,
                                MergeFileFavor = MergeFileFavor.Normal,
                                OnCheckoutProgress = (n, processed, total) =>
                                {
                                    t.PrintProgress((double) processed/total);
                                },
                            });

                        t.PrintResult(result.Status != MergeStatus.Conflicts);

                    }

                    if (result.Status == MergeStatus.UpToDate)
                    {
                        Console.WriteLine("Source was already up to date");
                        recompileNeeded = RestoreDeleteFiles(repo);
                        _.PrintResult(true);
                    }
                    else if (result.Status == MergeStatus.Conflicts)
                    {
                        throw new MergeConflictException();
                    }
                    else
                    {
                        Console.WriteLine("Updated to {0} : {1}", result.Commit.Sha.Substring(0, 10), result.Commit.MessageShort);
                        _.PrintResult(true);
                    }
                }
                catch (MergeConflictException)
                {
                    Console.WriteLine("Merge resulted in conflicts. This usually indictates a user-edited source");
                    Console.WriteLine("Your Aura will NOT be updated until you undo your changes to the files.");
                    Console.WriteLine("This is a bad thing, so fix it ASAP.");
                    Console.WriteLine("NOTE: If you're trying to make configuration changes, use the \"user\" folders instead.");
                    Console.WriteLine("Rolling back merge...");
                    repo.Reset(currentCommit);
                    recompileNeeded = false;
                    _.PrintResult(false);
                }

                return recompileNeeded;
            }
        }
 /// <summary>
 /// Sets the current <see cref="IRepository.Head"/> to the specified commit and optionally resets the <see cref="Index"/> and
 /// the content of the working tree to match.
 /// </summary>
 /// <param name="repository">The <see cref="IRepository"/> being worked with.</param>
 /// <param name="resetMode">Flavor of reset operation to perform.</param>
 /// <param name="commit">The target commit object.</param>
 public static void Reset(this IRepository repository, ResetMode resetMode, Commit commit)
 {
     repository.Reset(resetMode, commit, null, null);
 }
 /// <summary>
 /// Replaces entries in the <see cref="Repository.Index"/> with entries from the specified commit.
 /// </summary>
 /// <param name="repository">The <see cref="IRepository"/> being worked with.</param>
 /// <param name="commit">The target commit object.</param>
 /// <param name="paths">The list of paths (either files or directories) that should be considered.</param>
 public static void Reset(this IRepository repository, Commit commit, IEnumerable <string> paths)
 {
     repository.Reset(commit, paths, null);
 }
 private static void AssertStage(bool? ignorecase, IRepository repo, string path)
 {
     try
     {
         repo.Index.Stage(path);
         Assert.Equal(FileStatus.Added, repo.Index.RetrieveStatus(path));
         repo.Reset();
         Assert.Equal(FileStatus.Untracked, repo.Index.RetrieveStatus(path));
     }
     catch (ArgumentException)
     {
         Assert.False(ignorecase ?? true);
     }
 }
 public void Reset()
 {
     repository.Reset();
 }