Beispiel #1
0
        public bool GetSignature(SignatureLocations location, out string name, out string email)
        {
            lock (this)
            {
                name  = null;
                email = null;
                string globalValue;
                if (location == SignatureLocations.Global)
                {
                    globalValue = " --global";
                }
                else if (location == SignatureLocations.Local)
                {
                    globalValue = " --local";
                }
                else
                {
                    globalValue = string.Empty;
                }

                bool result = SimpleGitInvoke(string.Format("config{0} user.name", globalValue));
                name = lastResult;
                if (!result)
                {
                    return(false);
                }

                result = SimpleGitInvoke(string.Format("config{0} user.email", globalValue));
                email  = lastResult;
                return(result);
            }
        }
Beispiel #2
0
        public bool SetSignature(SignatureLocations location, string name, string email)
        {
            lock (this)
            {
                string globalValue;
                if (location == SignatureLocations.Global)
                {
                    globalValue = " --global";
                }
                else if (location == SignatureLocations.Local)
                {
                    globalValue = " --local";
                }
                else
                {
                    globalValue = string.Empty;
                }

                bool result = SimpleGitInvoke(string.Format("config{1} user.name \"{0}\"", name, globalValue));
                name = lastResult;
                if (!result)
                {
                    return(false);
                }

                result = SimpleGitInvoke(string.Format("config{1} user.email \"{0}\"", email, globalValue));
                email  = lastResult;
                return(result);
            }
        }
Beispiel #3
0
        public bool UpdateSignature(string name, string email, SignatureLocations location)
        {
            lock (this)
            {
                try
                {
                    // remove local sig
                    if (signatureIsLocal && location == SignatureLocations.Global)
                    {
                        repository.RemoveSettings(SignatureLocations.Local, "user");
                    }

                    // update sig
                    if (!repository.SetSignature(location, name, email))
                    {
                        throw new Exception(repository.lastError);
                    }
                    signatureName    = name;
                    signatureEmail   = email;
                    signatureIsLocal = location == SignatureLocations.Local;
                    return(true);
                }
                catch (Exception e)
                {
                    DebugLog.LogError("Update Signature: " + e.Message);
                    return(false);
                }
            }
        }
Beispiel #4
0
        public bool RemoveSettings(SignatureLocations location, string section)
        {
            lock (this)
            {
                string globalValue;
                if (location == SignatureLocations.Global)
                {
                    globalValue = " --global";
                }
                else if (location == SignatureLocations.Local)
                {
                    globalValue = " --local";
                }
                else
                {
                    globalValue = string.Empty;
                }

                return(SimpleGitInvoke(string.Format("config{1} --remove-section {0}", section, globalValue)));
            }
        }