Ejemplo n.º 1
0
 public GitRepository(string path)
 {
     Guard.Required(path, nameof(path));
     path = IOPath.GetFullPath(path);
     if (!IsRepository(path))
     {
         throw new ArgumentException("Not a path to a Git repository", nameof(path));
     }
     Path = path;
     Name = new GitRepositoryName(IOPath.GetFileName(path));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialise a new Git URL
        /// </summary>
        ///
        /// <param name="gitUrlString">
        /// A Git URL string
        /// </param>
        ///
        /// <exception cref="ArgumentNullException">
        /// <paramref name="gitUrlString"/> was <c>null</c>
        /// </exception>
        ///
        /// <exception cref="FormatException">
        /// <paramref name="gitUrlString"/> was not a valid Git URL
        /// </exception>
        ///
        public GitUrl(string gitUrlString)
            : base(CheckGitUrlString(gitUrlString), UriKind.Absolute)
        {
            if (!GitSchemes.Contains(Scheme.ToUpperInvariant()))
            {
                throw new FormatException("Invalid Git URL scheme");
            }
            if (Query != "")
            {
                throw new FormatException("Query components are not permitted in Git URLs");
            }
            if (Fragment != "")
            {
                throw new FormatException("Fragment components are not permitted in Git URLs");
            }

            RepositoryName = new GitRepositoryName(Path.GetFileNameWithoutExtension(AbsolutePath));
        }