Beispiel #1
0
 Clone(string parentPath, GitUrl url)
 {
     using (LogicalOperation.Start($"Cloning {url}"))
     {
         GitRepository.Clone(parentPath, url);
     }
 }
Beispiel #2
0
        public override bool Equals(object obj)
        {
            TemplateSource other = obj as TemplateSource;

            if (other == null)
            {
                return(false);
            }
            if (Type != other.Type)
            {
                return(false);
            }

            if (SourceFolder != null && !SourceFolder.Equals(other.SourceFolder))
            {
                return(false);
            }

            if (GitUrl != null && !GitUrl.Equals(other.GitUrl))
            {
                return(false);
            }

            if (PackageVersion != null && !PackageVersion.Equals(other.PackageVersion))
            {
                return(false);
            }

            if (PackageName != null && !PackageName.Equals(other.PackageName))
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        public void SetAttributeString()
        {
            var attributes = this.GetAttributes();

            if (!string.IsNullOrEmpty(Language))
            {
                attributes.AddClass($"lang-{Language}");
            }

            if (IsInteractive)
            {
                attributes.AddProperty("data-interactive", WebUtility.HtmlEncode(Language));
            }

            if (GitUrl != null && GitUrl.StartsWith("https://github.com", StringComparison.OrdinalIgnoreCase))
            {
                attributes.AddProperty("data-src", WebUtility.HtmlEncode(GitUrl));
            }

            if (!string.IsNullOrEmpty(Name))
            {
                attributes.AddProperty("name", Name);
            }

            if (!string.IsNullOrEmpty(Title))
            {
                attributes.AddProperty("title", Title);
            }

            var highlightRangesString = GetHighlightLinesString();
            if (highlightRangesString != string.Empty)
            {
                attributes.AddProperty("highlight-lines", highlightRangesString);
            }
        }
Beispiel #4
0
        public override int GetHashCode()
        {
            int hashcode = Type.GetHashCode();

            if (SourceFolder != null)
            {
                hashcode += SourceFolder.GetHashCode();
            }
            if (SourceRelPath != null)
            {
                hashcode += SourceRelPath.GetHashCode();
            }
            if (PackageName != null)
            {
                hashcode += PackageName.GetHashCode();
            }
            if (PackageVersion != null)
            {
                hashcode += PackageVersion.GetHashCode();
            }
            if (GitUrl != null)
            {
                hashcode += GitUrl.GetHashCode();
            }
            if (GitBranch != null)
            {
                hashcode += GitBranch.GetHashCode();
            }
            return(hashcode);
        }
Beispiel #5
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(GitUrl != null ? GitUrl.GetHashCode() : 0);
     }
 }
Beispiel #6
0
        LockDependency(GitUrl url, GitCommitName commitName, GitCommitName commitId)
            : base(url, commitName)
        {
            Guard.NotNull(commitId, nameof(commitId));

            CommitId = commitId;
        }
Beispiel #7
0
        Dependency(GitUrl url, GitCommitName commitName)
        {
            Guard.NotNull(url, nameof(url));
            Guard.NotNull(commitName, nameof(commitName));

            Url        = url;
            CommitName = commitName;
        }
Beispiel #8
0
 public void GetRemote(Action <PackageListConfig> onConfigReceived)
 {
     ObservableWWW.Get(GitUrl.Append("/raw/master/PackageList.json").ToString())
     .Subscribe(jsonCotnent =>
     {
         onConfigReceived(SerializeHelper.FromJson <PackageListConfig>(jsonCotnent));
     }, err =>
     {
         Log.E(err);
     });
 }
Beispiel #9
0
        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);
        }
Beispiel #10
0
 public string GetCustomGitUrl(string path)
 {
     // Return a custom git url, e.g. http://kuduservice/git/foo/bar
     return(GitUrl.Substring(0, GitUrl.LastIndexOf("/")) + "/git/" + path);
 }
Beispiel #11
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);
        }
Beispiel #12
0
 public PackageListConfig SaveExport(string gitServerUrl = null)
 {
     this.SaveJson(Application.dataPath.CombinePath(gitServerUrl.IsNullOrEmpty() ? GitUrl.GetLastWord() : gitServerUrl.GetLastWord()).CombinePath("PackageList.json"));
     return(this);
 }
Beispiel #13
0
 public override int GetHashCode()
 {
     unchecked
     {
         return((Name != null ? Name.GetHashCode() : 0) ^ (Path != null ? Path.GetHashCode() : 0) ^ (Sha != null ? Sha.GetHashCode() : 0) ^ (Size != null ? Size.GetHashCode() : 0) ^ (Url != null ? Url.GetHashCode() : 0) ^ (HtmlUrl != null ? HtmlUrl.GetHashCode() : 0) ^ (GitUrl != null ? GitUrl.GetHashCode() : 0) ^ (Type != null ? Type.GetHashCode() : 0));
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         return((Type != null ? Type.GetHashCode() : 0) ^ (Sha != null ? Sha.GetHashCode() : 0) ^ (Path != null ? Path.GetHashCode() : 0) ^ (GitUrl != null ? GitUrl.GetHashCode() : 0) ^ (HtmlUrl != null ? HtmlUrl.GetHashCode() : 0) ^ (DownloadUrl != null ? DownloadUrl.GetHashCode() : 0) ^ (Encoding != null ? Encoding.GetHashCode() : 0) ^ (Url != null ? Url.GetHashCode() : 0) ^ (Size != null ? Size.GetHashCode() : 0) ^ (Name != null ? Name.GetHashCode() : 0) ^ (Content != null ? Content.GetHashCode() : 0));
     }
 }