Ejemplo n.º 1
0
        private static SPath TryGetFile(ResourceType resourceType, string resource, IEnvironment environment)
        {
            /*
             *      This function attempts to get files embedded in the callers assembly.
             *
             *      Each file's name is their physical path in the project.
             *
             *      First check for the resource in the calling assembly.
             *      If the resource is still not found, it attempts to find it in the file system
             */

            (string type, string os) = ParseResourceType(resourceType, environment);

            var stream = TryGetResource(resourceType, type, os, resource);

            if (stream != null)
            {
                var target = SPath.GetTempFilename();
                return(target.WriteAllBytes(stream.ToByteArray()));
            }

            SPath possiblePath = environment.ExtensionInstallPath.Combine(type, os, resource);

            if (possiblePath.FileExists())
            {
                return(possiblePath);
            }

            return(SPath.Default);
        }
Ejemplo n.º 2
0
        public GitCommitTask(IPlatform platform,
                             string message, string body,
                             CancellationToken token = default)
            : base(platform, null, outputProcessor: new StringOutputProcessor(), token: token)
        {
            Guard.ArgumentNotNullOrWhiteSpace(message, "message");

            this.message = message;
            this.body    = body ?? string.Empty;

            Name      = TaskName;
            tempFile  = SPath.GetTempFilename("GitCommitTask");
            arguments = $"-c i18n.commitencoding=utf8 commit --file \"{tempFile}\"";
        }
Ejemplo n.º 3
0
        private static SPath TryGetFile(ResourceType resourceType, string resource, IGitEnvironment environment)
        {
            /*
             *  This function attempts to get files embedded in the callers assembly.
             *  Unity.VersionControl.Git which tends to contain logos
             *  Git.Api which tends to contain application resources
             *
             *  Each file's name is their physical path in the project.
             *
             *  When running tests, we assume the tests are looking for application resources, and default to returning Git.Api
             *
             *  First check for the resource in the calling assembly.
             *  If the resource cannot be found, fallback to looking in Git.Api's assembly.
             *  If the resource is still not found, it attempts to find it in the file system
             */

            (string type, string os) = ParseResourceType(resourceType, environment);

            var stream = TryGetResource(resourceType, type, os, resource);

            if (stream != null)
            {
                var target = SPath.GetTempFilename();
                return(target.WriteAllBytes(stream.ToByteArray()));
            }

            SPath possiblePath = environment.ExtensionInstallPath.Combine(type, os, resource);

            if (possiblePath.FileExists())
            {
                return(possiblePath);
            }

            var basePath = resourceType == ResourceType.Icon ? "Editor" : "Api";

            possiblePath = environment.ExtensionInstallPath.Parent.Combine(basePath, type, os, resource);
            if (possiblePath.FileExists())
            {
                return(possiblePath);
            }

            return(SPath.Default);
        }