当前位置: 首页>>代码示例>>C#>>正文


C# Repository.Dispose方法代码示例

本文整理汇总了C#中LibGit2Sharp.Repository.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Dispose方法的具体用法?C# Repository.Dispose怎么用?C# Repository.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LibGit2Sharp.Repository的用法示例。


在下文中一共展示了Repository.Dispose方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main(string[] args)
        {
            var result = CommandLine.Parser.Default.ParseArguments<Options>(args);
              if (!result.Errors.Any())
              {
            string url = result.Value.Repository;

            var brancOption = result.Value.Branch;
            var branchSepIndex = brancOption.IndexOf('/');
            if (branchSepIndex > 0)
            {
              var credentials = new UsernamePasswordCredentials
            {
              Username = result.Value.UserName,
              Password = result.Value.Password
            };
              CredentialsHandler credHandler = (s, fromUrl, types) => credentials;

              var remote = brancOption.Substring(0, branchSepIndex);
              var branch = brancOption.Substring(branchSepIndex+1, brancOption.Length - branchSepIndex-1);

              var workingDirectory = result.Value.LocalRepoPath;

              var isLocalRepoExist = Repository.Discover(workingDirectory);
              if (isLocalRepoExist == null)
              {
            var cloneOptions = new CloneOptions {CredentialsProvider = credHandler};
            Repository.Clone(url, workingDirectory, cloneOptions);
              }

              Repository repo = null;
              try
              {
            var tagName = result.Value.TagName;
            repo = new Repository(workingDirectory);
            //repo.Fetch(remote, new FetchOptions(){CredentialsProvider = credHandler});
            repo.Network.Pull(new Signature(result.Value.UserName,result.Value.Email, new DateTimeOffset()),
              new PullOptions() { FetchOptions = new FetchOptions() { CredentialsProvider = credHandler } });
            repo.ApplyTag(tagName);
            PushChanges(repo, credHandler, remote, branch, tagName);
            Console.WriteLine("Tagged :{0}", result.Value.TagName);
              }
              catch (Exception ex)
              {
            Console.WriteLine("Error happened {0}", ex.Message);
              }
              finally
              {
            if (repo != null) repo.Dispose();
              }
            }
              }
              Console.ReadLine();
        }
开发者ID:keannan5390,项目名称:git-tag-sharp,代码行数:54,代码来源:Program.cs

示例2: RepositoryWrapper

 public RepositoryWrapper(Repository repo)
 {
     this.repo = repo;
     Head = async (i) => { return new BranchWrapper(repo, repo.Head); };
     Config = async (i) => { return repo.Config; };
     Index = async (i) => { return repo.Index; };
     Ignore = async (i) => { return repo.Ignore; };
     Network = async (i) => { return new NetworkWrapper(repo.Network); };
     ObjectDatabase = async (i) => { return repo.ObjectDatabase; };
     Refs = async (i) => { return repo.Refs; };
     Commits = async (i) => { return repo.Commits.Select(c => new CommitWrapper(c)); };
     Tags = async (i) => { return repo.Tags; };
     Stashes = async (i) => { return repo.Stashes; };
     Info = async (i) => { return repo.Info; };
     Diff = async (i) => { return repo.Diff; };
     Notes = async (i) => { return repo.Notes; };
     Submodules = async (i) => { return repo.Submodules; };
     Dispose = async (i) => { repo.Dispose(); return null; };
     Lookup = async (id) => {
         var found = repo.Lookup(id.ToString());
         if (found.GetType() == typeof(Commit)) {
             return new CommitWrapper((Commit)found);
         } else {
             return found;
         }
     };
     Branches = async (i) => repo.Branches.Select(b => new BranchWrapper(repo, b)).ToDictionary(b => b.Name);
     Reset = async (dynamic i) => {
         var modeName = ((string)i.mode).ToLower();
         ResetMode mode;
         if (modeName == "soft") {
             mode = ResetMode.Soft;
         } else if (modeName == "mixed") {
             mode = ResetMode.Mixed;
         } else {
             mode = ResetMode.Hard;
         }
         var committish = (string)i.committish;
         repo.Reset(mode, committish, null, null);
         return null;
     };
     Checkout = async (i) => {
         var branch = repo.Branches.First(b => b.Name == i.ToString());
         repo.Checkout(branch);
         return branch;
     };
 }
开发者ID:itsananderson,项目名称:edge-git,代码行数:47,代码来源:RepositoryWrapper.cs

示例3: LastCommitTime

        public IObservable<DateTimeOffset> LastCommitTime(string repoPath)
        {
            return Observable.Start(() => {
                var repo = default(Repository);
                try {
                    repo = new Repository(repoPath);
                    if (repo.Head == null || repo.Head.Tip == null) {
                        throw new Exception("Couldn't find commit");
                    }

                    this.Log().Debug("Last Commit Time: {0}", repo.Head.Tip.Author.When);
                    return repo.Head.Tip.Author.When;
                } catch (Exception ex) {
                    this.Log().WarnException("Couldn't read commit time on repo: " + repoPath, ex);
                    throw;
                } finally {
                    if (repo != null) repo.Dispose();
                }
            }, RxApp.TaskpoolScheduler);
        }
开发者ID:jaredpar,项目名称:SaveAllTheTime,代码行数:20,代码来源:GitRepoOps.cs

示例4: GetStatus

 public IObservable<RepositoryStatus> GetStatus(string repoPath)
 {
     return Observable.Start(() => {
         var repo = default(Repository);
         try {
             repo = new Repository(repoPath);
             return repo.Index.RetrieveStatus();
         } catch (Exception ex) {
             this.Log().WarnException("Couldn't read status for repo: " + repoPath, ex);
             throw;
         } finally {
             if (repo != null) repo.Dispose();
         }
     }, RxApp.TaskpoolScheduler);
 }
开发者ID:jaredpar,项目名称:SaveAllTheTime,代码行数:15,代码来源:GitRepoOps.cs

示例5: ProtocolUrlForRepoPath

        public string ProtocolUrlForRepoPath(string repoPath)
        {
            if (!isGitHubForWindowsInstalled()) return null;

            var remoteUrl = default(string);
            var repo = default(Repository);

            try {
                repo = new Repository(repoPath);
                var remote = repo.Network.Remotes.FirstOrDefault(x => x.Name.Equals("origin", StringComparison.OrdinalIgnoreCase));
                if (remote == null) return null;

                this.Log().Info("Using remote {0} for repo {1}", remote.Url, repoPath);
                remoteUrl = remote.Url.ToLowerInvariant();
            } catch (Exception ex) {
                this.Log().WarnException("Failed to open repo: " + repoPath, ex);
                return null;
            } finally {
                if (repo != null) repo.Dispose();
            }

            var ret = protocolUrlForRemoteUrl(remoteUrl);
            this.Log().Info("Protocol URL for {0} is {1}", repoPath, ret);
            return ret;
        }
开发者ID:jaredpar,项目名称:SaveAllTheTime,代码行数:25,代码来源:GitRepoOps.cs

示例6: OnPublish

		protected override Repository OnPublish (string serverPath, FilePath localPath, FilePath[] files, string message, ProgressMonitor monitor)
		{
			// Initialize the repository
			RootRepository = new LibGit2Sharp.Repository (LibGit2Sharp.Repository.Init (localPath));
			RootPath = localPath;
			RootRepository.Network.Remotes.Add ("origin", Url);

			// Add the project files
			ChangeSet cs = CreateChangeSet (localPath);
			foreach (FilePath fp in files) {
				RootRepository.Stage (RootRepository.ToGitPath (fp));
				cs.AddFile (fp);
			}

			// Create the initial commit
			cs.GlobalComment = message;
			Commit (cs, monitor);

			RootRepository.Branches.Update (RootRepository.Branches ["master"], branch => branch.TrackedBranch = "refs/remotes/origin/master");

			RetryUntilSuccess (monitor, credType => RootRepository.Network.Push (RootRepository.Head, new PushOptions {
				OnPushStatusError = delegate (PushStatusError e) {
					RootRepository.Dispose ();
					RootRepository = null;
					if (RootPath.Combine (".git").IsDirectory)
						Directory.Delete (RootPath.Combine (".git"), true);
					throw new VersionControlException (e.Message);
				},
				CredentialsProvider = (url, userFromUrl, types) => GitCredentials.TryGet (url, userFromUrl, types, credType)
			}));

			return this;
		}
开发者ID:powerumc,项目名称:monodevelop_korean,代码行数:33,代码来源:GitRepository.cs

示例7: StartDeploying


//.........这里部分代码省略.........

                Tag tagOlder = repository.Tags.FirstOrDefault(x => x.Name == olderVersion);
                Tag tagNewer = repository.Tags.FirstOrDefault(x => x.Name == newerVersion);

                if (tagOlder == null || tagNewer == null)
                {
                    if (tagOlder == null)
                    {
                        Printf("Invalid older tag");
                    }
                    if (tagNewer == null)
                    {
                        Printf("Invalid newer tag");
                    }
                }
                else
                {
                    commitOlder = tagOlder.Target as Commit;
                    commitNewer = tagNewer.Target as Commit;

                    if (commitOlder == null || commitNewer == null)
                    {
                        if (commitOlder == null)
                        {
                            Printf("Older tag does not point to commit");
                        }
                        if (commitNewer == null)
                        {
                            Printf("Newer tag does not point to commit");
                        }
                    }
                    else
                    {
                        if (commitOlder.Author.When >= commitNewer.Author.When)
                        {
                            Printf("Wrong timing");
                        }
                        else
                        {
                            wrongInput = false;
                        }
                    }
                }
            }

            TreeChanges changes = repository.Diff.Compare<TreeChanges>(commitOlder.Tree, commitNewer.Tree);

            PrintChanges(changes);
            LogChanges(changes);

            List<TreeEntryChanges> filesToBeBackedUp = new List<TreeEntryChanges>();
            filesToBeBackedUp.AddRange(changes.Modified);
            filesToBeBackedUp.AddRange(changes.Deleted);
            filesToBeBackedUp.AddRange(changes.Renamed);

            List<TreeEntryChanges> filesToBeDeployed = new List<TreeEntryChanges>();
            filesToBeDeployed.AddRange(changes.Added);
            filesToBeDeployed.AddRange(changes.Modified);
            filesToBeDeployed.AddRange(changes.Renamed);

            string backUpPath = string.Format("{0}{1}", TmpPath, "backup\\");
            string deployPath = string.Format("{0}{1}", TmpPath, "deploy\\");
            fileManager.CreateTmpFolder(TmpPath);

            BundleCreationResult backupResult;
            BundleCreationResult deployResult;
            BundleCreationResult rollBackResult;
            BundleCreationResult deployPackResult;

            Printf("Creating backup");
            backupResult = fileManager.CreateBackUp(ServerPath, backUpPath, filesToBeBackedUp);
            PrintResult("Creating backup", backupResult);

            if (backupResult == BundleCreationResult.Succes)
            {
                Printf("Creating deploy pack");
                deployPackResult = fileManager.CreateDeployPack(BaseRepositoryPath, deployPath, filesToBeDeployed);
                PrintResult("Creating deploy pack", deployPackResult);

                if (deployPackResult == BundleCreationResult.Succes)
                {
                    Printf("Deploying files");
                    deployResult = fileManager.DeployFiles(deployPath, ServerPath, changes, BaseRepositoryPath);
                    PrintResult("Deploying files", deployResult);

                    if (deployResult == BundleCreationResult.Fail)
                    {
                        Printf("Rolling back");
                        rollBackResult = fileManager.RollBack(backUpPath, ServerPath, changes);
                        PrintResult("Rolling back", rollBackResult);
                    }
                }
            }

            Printf("Generating Zip");
            fileManager.GenerateZip(ZipFilePath, TmpPath, filesToBeBackedUp, filesToBeDeployed, olderVersion.Replace(".", "_"), newerVersion.Replace(".", "_"));

            fileManager.DeleteTmpFolder(TmpPath);
            repository.Dispose();
        }
开发者ID:3osoft,项目名称:fileDeployer,代码行数:101,代码来源:Program.cs

示例8: fetchLatestCommitForHead

        Commit fetchLatestCommitForHead(string repositoryRoot)
        {
            if (String.IsNullOrEmpty(repositoryRoot)) {
                return null;
            }

            var repo = default(Repository);
            try {
                repo = new Repository(repositoryRoot);
                return repo.Commits.FirstOrDefault();
            } catch (Exception ex) {
                this.Log().ErrorException("Couldn't open repo", ex);
                return null;
            } finally {
                if (repo != null) {
                    repo.Dispose();
                }
            }
        }
开发者ID:paulcbetts,项目名称:Shotclock,代码行数:19,代码来源:MainViewModel.cs


注:本文中的LibGit2Sharp.Repository.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。