예제 #1
0
        public static AsyncOperation RemoveSubmodule(string localRelativeSubmodulePath)
        {
            if (localRelativeSubmodulePath == null)
            {
                throw new ArgumentNullException("localRelativeSubmodulePath");
            }

            var projectRoot = Project.RootDirectory;

            var operation = new AsyncOperation();

            // Remove from gitmodules
            operation.AddSync(() =>
            {
                RemoveFromGitConfig(projectRoot + "/.gitmodules", localRelativeSubmodulePath);
            });

            // stage that change
            operation.Add(new GitTask("add .gitmodules"));

            // remove lines in .git/config
            operation.AddSync(() =>
            {
                RemoveFromGitConfig(projectRoot + "/.git/config", localRelativeSubmodulePath);
            });

            // Delete the actual files
            operation.Add(new GitTask("rm --cached -f " + localRelativeSubmodulePath));

            // Run rm -rf .git/modules/path_to_submodule (no trailing slash).
            operation.AddSync(() =>
            {
                var directory = projectRoot + "/.git/modules/" + localRelativeSubmodulePath;
                FileUtil.DeleteFileOrDirectory(directory);
            });

            // Delete the now untracked submodule files rm -rf path_to_submodule
            operation.AddSync(() =>
            {
                var directory = projectRoot + "/" + localRelativeSubmodulePath;
                FileUtil.DeleteFileOrDirectory(directory);
            });

            return(operation);
        }
예제 #2
0
        public static AsyncOperation CompilePackageListStatus()
        {
            var operation         = new AsyncOperation();
            var packageListStatus = new PackageListStatus();

            foreach (var package in RootStore.Instance.Packages.InstalledPackages.Value.Packages)
            {
                var packageStatus = new PackageStatus
                {
                    RequiredVersion = package.Version,
                    PackageName     = package.Name,
                    GitUrl          = package.GitUrl
                };
                packageListStatus.Packages.Add(packageStatus);
                var packageDirectory = Settings.AbsolutePackagesDirectoryPath + package.Name;
                if (!Directory.Exists(packageDirectory))
                {
                    packageStatus.IsMissing = true;
                    continue;
                }

                var getGitBranchOrTagTask = new GetGitBranchOrTagTask(package);
                var packageVersion        = package.Version;
                operation.Add(getGitBranchOrTagTask, (result, op) =>
                {
                    packageStatus.IsOnWrongVersion = result.Data != packageVersion;
                });
            }

            operation.AddSync(() =>
            {
                Debug.Log("Project package status: ");

                foreach (var package in packageListStatus.Packages)
                {
                    Debug.Log(package);
                }

                Debug.Log("The project is " +
                          (packageListStatus.IsProjectUpToDate ? "" : "not ") + "up to date");

                return(new Result <PackageListStatus>(packageListStatus));
            }, (result, op) =>
            {
                op.Complete(result);
            });

            return(operation);
        }