GitSharp.Core.Repository.ShortenRefName C# (CSharp) Method

ShortenRefName() public static method

public static ShortenRefName ( string refName ) : string
refName string
return string
        public static string ShortenRefName(string refName)
        {
            if (refName.StartsWith(Constants.R_HEADS))
            {
                return refName.Substring(Constants.R_HEADS.Length);
            }

            if (refName.StartsWith(Constants.R_TAGS))
            {
                return refName.Substring(Constants.R_TAGS.Length);
            }

            if (refName.StartsWith(Constants.R_REMOTES))
            {
                return refName.Substring(Constants.R_REMOTES.Length);
            }

            return refName;
        }

Usage Example

Example #1
0
        /// <summary>
        /// Initialize a new rename operation.
        /// </summary>
        /// <param name="src">operation to read and delete the source.</param>
        /// <param name="dst">operation to create (or overwrite) the destination.</param>
        protected RefRename(RefUpdate src, RefUpdate dst)
        {
            source      = src;
            destination = dst;

            Repository repo = destination.getRepository();
            string     cmd  = "";

            if (source.getName().StartsWith(Constants.R_HEADS) &&
                destination.getName().StartsWith(Constants.R_HEADS))
            {
                cmd = "Branch: ";
            }
            setRefLogMessage(cmd + "renamed "
                             + repo.ShortenRefName(source.getName()) + " to "
                             + repo.ShortenRefName(destination.getName()));
        }
All Usage Examples Of GitSharp.Core.Repository::ShortenRefName