Esempio n. 1
0
        bool ReadStream(GitCommand command)
        {
            StreamReader output_stream = command.StandardError;

            if (StorageType == StorageType.LargeFiles)
            {
                output_stream = command.StandardOutput;
            }

            double percentage  = 0;
            double speed       = 0;
            string information = "";

            while (!output_stream.EndOfStream)
            {
                string      line  = output_stream.ReadLine();
                ErrorStatus error = GitCommand.ParseProgress(line, out percentage, out speed, out information);

                if (error != ErrorStatus.None)
                {
                    Error       = error;
                    information = line;

                    command.Kill();
                    command.Dispose();
                    Logger.LogInfo("Git", Name + " | Error status changed to " + Error);

                    return(false);
                }

                OnProgressChanged(percentage, speed, information);
            }

            return(true);
        }
Esempio n. 2
0
        public override void Stop()
        {
            try {
                if (git_clone != null && !git_clone.HasExited)
                {
                    git_clone.Kill();
                    git_clone.Dispose();
                }
            } catch (Exception e) {
                Logger.LogInfo("Fetcher", "Failed to dispose properly", e);
            }

            if (Directory.Exists(TargetFolder))
            {
                try {
                    Directory.Delete(TargetFolder, recursive: true);
                    Logger.LogInfo("Fetcher", "Deleted '" + TargetFolder + "'");
                } catch (Exception e) {
                    Logger.LogInfo("Fetcher", "Failed to delete '" + TargetFolder + "'", e);
                }
            }
        }
Esempio n. 3
0
        public override bool Fetch()
        {
            if (!base.Fetch())
            {
                return(false);
            }

            StorageType?storage_type = DetermineStorageType();

            if (storage_type == null)
            {
                return(false);
            }

            FetchedRepoStorageType = (StorageType)storage_type;

            string git_clone_command = "clone --progress --no-checkout";

            if (!FetchPriorHistory)
            {
                git_clone_command += " --depth=1";
            }

            if (storage_type == StorageType.LargeFiles)
            {
                git_clone_command = "lfs clone --progress --no-checkout";
            }

            git_clone = new GitCommand(Configuration.DefaultConfiguration.TmpPath,
                                       string.Format("{0} \"{1}\" \"{2}\"", git_clone_command, RemoteUrl, TargetFolder),
                                       auth_info);

            git_clone.StartInfo.RedirectStandardError = true;
            git_clone.Start();

            StreamReader output_stream = git_clone.StandardError;

            if (FetchedRepoStorageType == StorageType.LargeFiles)
            {
                output_stream = git_clone.StandardOutput;
            }

            double percentage  = 0;
            double speed       = 0;
            string information = "";

            while (!output_stream.EndOfStream)
            {
                string line = output_stream.ReadLine();

                ErrorStatus error = GitCommand.ParseProgress(line, out percentage, out speed, out information);

                if (error != ErrorStatus.None)
                {
                    IsActive = false;
                    git_clone.Kill();
                    git_clone.Dispose();

                    return(false);
                }

                OnProgressChanged(percentage, speed, information);
            }

            git_clone.WaitForExit();

            if (git_clone.ExitCode != 0)
            {
                return(false);
            }

            Thread.Sleep(500);
            OnProgressChanged(100, 0, "");
            Thread.Sleep(500);

            return(true);
        }
Esempio n. 4
0
        public override bool Fetch()
        {
            if (!base.Fetch ())
                return false;

            StorageType? storage_type = DetermineStorageType ();

            if (storage_type == null)
                return false;

            FetchedRepoStorageType = (StorageType) storage_type;

            string git_clone_command = "clone --progress --no-checkout";

            if (!FetchPriorHistory)
                git_clone_command += " --depth=1";

            if (storage_type == StorageType.LargeFiles)
                git_clone_command = "lfs clone --progress --no-checkout";

            git_clone = new GitCommand (Configuration.DefaultConfiguration.TmpPath,
                string.Format ("{0} \"{1}\" \"{2}\"", git_clone_command, RemoteUrl, TargetFolder),
                auth_info);

            git_clone.StartInfo.RedirectStandardError = true;
            git_clone.Start ();

            StreamReader output_stream = git_clone.StandardError;

            if (FetchedRepoStorageType == StorageType.LargeFiles)
                output_stream = git_clone.StandardOutput;

            double percentage = 0;
            double speed = 0;
            string information = "";

            while (!output_stream.EndOfStream) {
                string line = output_stream.ReadLine ();

                ErrorStatus error = GitCommand.ParseProgress (line, out percentage, out speed, out information);

                if (error != ErrorStatus.None) {
                    IsActive = false;
                    git_clone.Kill ();
                    git_clone.Dispose ();

                    return false;
                }

                OnProgressChanged (percentage, speed, information);
            }

            git_clone.WaitForExit ();

            if (git_clone.ExitCode != 0)
                return false;

            Thread.Sleep (500);
            OnProgressChanged (100, 0, "");
            Thread.Sleep (500);

            return true;
        }
Esempio n. 5
0
        bool ReadStream(GitCommand command)
        {
            StreamReader output_stream = command.StandardError;

            if (StorageType == StorageType.LargeFiles)
                output_stream = command.StandardOutput;

            double percentage = 0;
            double speed = 0;
            string information = "";

            while (!output_stream.EndOfStream) {
                string line = output_stream.ReadLine ();
                ErrorStatus error = GitCommand.ParseProgress (line, out percentage, out speed, out information);

                if (error != ErrorStatus.None) {
                    Error = error;
                    information = line;

                    command.Kill ();
                    command.Dispose ();
                    Logger.LogInfo ("Git", Name + " | Error status changed to " + Error);

                    return false;
                }

                OnProgressChanged (percentage, speed, information);
            }

            return true;
        }