示例#1
0
 protected override bool DrawWizardGUI()
 {
     EditorGUILayout.LabelField(GitGUI.GetTempContent("Stash Message:"));
     stashMessage   = EditorGUILayout.TextArea(stashMessage, GUILayout.Height(EditorGUIUtility.singleLineHeight * 6));
     stashModifiers = (StashModifiers)EditorGUILayout.EnumFlagsField("Stash Modifiers", stashModifiers);
     return(false);
 }
示例#2
0
        public IGitStashResults SaveStash(IGitStashSaveOptions options)
        {
            lock (lockObject)
            {
                if (repo == null)
                {
                    return(new GitStashResultsFailure(T["Repository not initialized"]));
                }
                if (projects.IsDirty)
                {
                    Logger.WriteLine(T["Your project has not been saved, aborting"]);
                    return(new GitStashResultsFailure(T["Your project has not been saved"]));
                }
                Logger.WriteLine(T["Saving stash: {0}", options.Message]);
                bool hasChanges = WorkingDirHasChanges();
                int  count      = repo.Stashes.Count();
                if (!repo.RetrieveStatus().IsDirty)
                {
                    Logger.WriteLine(T["Nothing to save."]);
                    return(new GitStashResultsFailure(T["Nothing to stash."]));
                }
                StashModifiers sm = (options.KeepIndex ? StashModifiers.KeepIndex : 0);
                sm |= (options.Untracked ? StashModifiers.IncludeUntracked : 0);
                sm |= (options.Ignored ? StashModifiers.IncludeIgnored : 0);
                Stash stash = repo.Stashes.Add(Stasher, options.Message, sm);

                GitStashResults results = new GitStashResults(stash, T["Succesfully saved stash."]);
                if (results.Success == false)
                {
                    Logger.WriteLine(T["Failed."]);
                    results.Message = T["Failed to save stash."];
                }
                if (repo.Stashes.Count() <= count && results.Success)
                {
                    Logger.WriteLine(T["Failed."]);
                    throw new GitStashException("Command save was called and reported success, but stash didn't increase.");
                }
                if (results.Success == false)
                {
                    if (stash != null)
                    {
                        LogFilesInStash(stash);
                    }
                    if (hasChanges)
                    {
                        Logger.WriteLine(T["perhaps you have untracked files, and didn't select Untracked."]);
                        results.Message = T["perhaps you have untracked files, and didn't select Untracked."];
                    }
                    Logger.WriteLine(T["Failed."]);
                    OnStashesChanged(new StashesChangedEventArgs());
                    return(results);
                }
                LogFilesInStash(stash);
                Logger.WriteLine(T["Done."] + Environment.NewLine);
                OnStashesChanged(new StashesChangedEventArgs());
                return(results);
            }
        }
示例#3
0
        /// <summary>
        /// Creates a stash with the specified message.
        /// </summary>
        /// <param name="stasher">The <see cref="Signature"/> of the user who stashes </param>
        /// <param name="message">The message of the stash.</param>
        /// <param name="options">A combination of <see cref="StashModifiers"/> flags</param>
        /// <returns>the newly created <see cref="Stash"/></returns>
        public virtual Stash Add(Signature stasher, string message = null, StashModifiers options = StashModifiers.Default)
        {
            Ensure.ArgumentNotNull(stasher, "stasher");

            string prettifiedMessage = Proxy.git_message_prettify(string.IsNullOrEmpty(message) ? string.Empty : message);

            ObjectId oid = Proxy.git_stash_save(repo.Handle, stasher, prettifiedMessage, options);

            // in case there is nothing to stash
            if (oid == null)
            {
                return(null);
            }

            return(new Stash(repo, oid, 0));
        }
示例#4
0
 /// <summary>
 /// Creates a stash with the specified message.
 /// </summary>
 /// <param name="stasher">The <see cref="Signature"/> of the user who stashes </param>
 /// <param name="options">A combination of <see cref="StashModifiers"/> flags</param>
 /// <returns>the newly created <see cref="Stash"/></returns>
 public virtual Stash Add(Signature stasher, StashModifiers options)
 {
     return(Add(stasher, null, options));
 }