Esempio n. 1
0
        public void Pull(Git git, BusyIndicatorProgressMonitor monitor)
        {
            PullCommand command = git.Pull();

            command.SetProgressMonitor(monitor);

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, evt) =>
            {
                monitor.StartAction();

                try
                {
                    command.Call();
                }
                catch (JGitInternalException)
                {
                    // TODO:
                }
            };
            bw.RunWorkerCompleted += (s, evt) =>
            {
                monitor.CompleteAction();
            };
            bw.RunWorkerAsync();
        }
Esempio n. 2
0
        public void Fetch(Git git, BusyIndicatorProgressMonitor monitor)
        {
            FetchCommand command = git.Fetch();

            RefSpec spec = new RefSpec("refs/heads/master:refs/heads/FETCH_HEAD");

            command.SetRefSpecs(spec);
            command.SetProgressMonitor(monitor);

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, evt) =>
            {
                monitor.StartAction();

                try
                {
                    command.Call();
                }
                catch (JGitInternalException)
                {
                    // TODO:
                }
            };
            bw.RunWorkerCompleted += (s, evt) =>
            {
                monitor.CompleteAction();
            };
            bw.RunWorkerAsync();
        }
Esempio n. 3
0
        /// <summary>
        /// フェッチ
        /// </summary>
        /// <param name="git"></param>
        /// <param name="privateKeyData"></param>
        /// <param name="publicKeyData"></param>
        /// <param name="monitor"></param>
        public void Fetch(Git git, CloneEntity entity, string privateKeyData, string publicKeyData, BusyIndicatorProgressMonitor monitor)
        {
            var customConfigSessionFactory = new CustomConfigSessionFactory();

            customConfigSessionFactory.PrivateKey = privateKeyData;
            customConfigSessionFactory.PublicKey = publicKeyData;

            NGit.Transport.JschConfigSessionFactory.SetInstance(customConfigSessionFactory);

            UsernamePasswordCredentialsProvider creds = new UsernamePasswordCredentialsProvider(entity.UserName, entity.PassWord);

            FetchCommand command = git.Fetch();

            RefSpec spec = new RefSpec("refs/heads/master:refs/heads/FETCH_HEAD");

            command.SetRemoveDeletedRefs(true);
            command.SetRefSpecs(spec);
            command.SetProgressMonitor(monitor);
            command.SetCredentialsProvider(creds);

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, evt) =>
            {
                monitor.StartAction();

                try
                {
                    command.Call();
                }
                catch (JGitInternalException)
                {
                    // TODO:
                }
            };
            bw.RunWorkerCompleted += (s, evt) =>
            {
                monitor.CompleteAction();
            };
            bw.RunWorkerAsync();
        }
Esempio n. 4
0
        /// <summary>
        /// リモートリポジトリをローカルへ複製する
        /// </summary>
        /// <param name="entity">エンティティ</param>
        /// <param name="monitor">モニター</param>
        public void CloneRepository(CloneEntity entity, BusyIndicatorProgressMonitor monitor)
        {
            FilePath directory = entity.Path;

            CloneCommand clone = new CloneCommand();

            //clone.SetCloneAllBranches(true);
            clone.SetDirectory(directory);
            clone.SetURI(entity.Url);

            clone.SetProgressMonitor(monitor);

            if (entity.IsCredential)
            {
                UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider(entity.UserName, entity.PassWord);

                clone.SetCredentialsProvider(user);
            }
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, evt) =>
                {
                    monitor.StartAction();

                    try
                    {
                        clone.Call();
                    }
                    catch (JGitInternalException)
                    {
                        // TODO:
                    }
                };
            bw.RunWorkerCompleted += (s, evt) =>
                {
                    monitor.CompleteAction();
                };
            bw.RunWorkerAsync();
        }
Esempio n. 5
0
        /// <summary>
        /// リモートリポジトリをローカルへ複製する
        /// </summary>
        /// <param name="entity">エンティティ</param>
        /// <param name="privateKeyData">秘密鍵</param>
        /// <param name="publicKeyData">公開鍵</param>
        /// <param name="monitor">モニター</param>
        public void CloneRepository(CloneEntity entity, string privateKeyData, string publicKeyData, BusyIndicatorProgressMonitor monitor)
        {
            var customConfigSessionFactory = new CustomConfigSessionFactory();

            customConfigSessionFactory.PrivateKey = privateKeyData;
            customConfigSessionFactory.PublicKey = publicKeyData;

            NGit.Transport.JschConfigSessionFactory.SetInstance(customConfigSessionFactory);

            UsernamePasswordCredentialsProvider creds = new UsernamePasswordCredentialsProvider(entity.UserName, entity.PassWord);

            FilePath directory = entity.Path;
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, evt) =>
            {
                monitor.StartAction();

                try
                {
                    var git = Git.CloneRepository()
                                  .SetProgressMonitor(monitor)
                                  .SetDirectory(directory)
                                  .SetURI(entity.Url)
                                  .SetBranchesToClone(new Collection<string>() { "master" })
                                  .SetCredentialsProvider(creds)
                                  .Call();
                }
                catch (JGitInternalException)
                {
                    // TODO:
                }
            };
            bw.RunWorkerCompleted += (s, evt) =>
            {
                monitor.CompleteAction();
                //this.SettingHttpBufferSize(entity.Path);
            };
            bw.RunWorkerAsync();
            
        }