コード例 #1
0
ファイル: DependencyTraverser.cs プロジェクト: macro187/nugit
 CheckOut(NuGitRepository repository, GitCommitName commit)
 {
     using (LogicalOperation.Start($"Checking out {commit}"))
     {
         repository.Checkout(commit);
     }
 }
コード例 #2
0
        LockDependency(GitUrl url, GitCommitName commitName, GitCommitName commitId)
            : base(url, commitName)
        {
            Guard.NotNull(commitId, nameof(commitId));

            CommitId = commitId;
        }
コード例 #3
0
        Dependency(GitUrl url, GitCommitName commitName)
        {
            Guard.NotNull(url, nameof(url));
            Guard.NotNull(commitName, nameof(commitName));

            Url        = url;
            CommitName = commitName;
        }
コード例 #4
0
ファイル: DependencyUrl.cs プロジェクト: macro187/nugit
        DependencyUrl(string urlString)
            : base(
                Guard.NotNull(urlString, nameof(urlString)),
                UriKind.Absolute)
        {
            GitUrl url;

            try
            {
                url = new GitUrl(GetLeftPart(UriPartial.Path));
            }
            catch (FormatException fe)
            {
                throw new FormatException("Not a valid Git repository URL", fe);
            }

            GitCommitName commitName = new GitCommitName(DefaultCommitName);

            if (Fragment.Length > 1)
            {
                try
                {
                    commitName = new GitCommitName(Fragment.Substring(1));
                }
                catch (FormatException fe)
                {
                    throw new FormatException("URL fragment is not a valid Git commit name", fe);
                }
            }

            if (Query != "")
            {
                throw new FormatException("Query components are not permitted in dependency URLs");
            }

            Dependency = new Dependency(url, commitName);
        }
コード例 #5
0
        ReadDotNuGitLock()
        {
            if (!HasDotNuGitLock())
            {
                throw new InvalidOperationException(".nugit.lock not present");
            }

            var result     = new List <LockDependency>();
            int lineNumber = 0;

            foreach (var rawline in File.ReadLines(GetDotNuGitLockPath()))
            {
                lineNumber++;
                var line = rawline.Trim();

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                if (line.StartsWith("#", StringComparison.Ordinal))
                {
                    continue;
                }

                var a = line.Split(' ');
                if (a.Length != 3)
                {
                    throw new TextFileParseException(
                              "Expected URL, commit name, and commit ID",
                              lineNumber,
                              rawline);
                }

                GitUrl url;
                try
                {
                    url = new GitUrl(a[0]);
                }
                catch (FormatException fe)
                {
                    throw new TextFileParseException(
                              "Expected valid Git URL",
                              lineNumber,
                              rawline,
                              fe);
                }

                GitCommitName commitName;
                try
                {
                    commitName = new GitCommitName(a[1]);
                }
                catch (FormatException fe)
                {
                    throw new TextFileParseException(
                              "Expected valid Git commit name",
                              lineNumber,
                              rawline,
                              fe);
                }

                GitCommitName commitId;
                try
                {
                    commitId = new GitCommitName(a[2]);
                }
                catch (FormatException fe)
                {
                    throw new TextFileParseException(
                              "Expected valid Git commit identifier",
                              lineNumber,
                              rawline,
                              fe);
                }

                result.Add(new LockDependency(url, commitName, commitId));
            }

            return(result);
        }