Example #1
0
 private async Task <GitClient> CreateClientAsync(IRepositoryMonitorContext context)
 {
     if (!string.IsNullOrEmpty(this.GitExePath))
     {
         this.LogDebug($"Executable path specified, using Git command line client at \"{this.GitExePath}\"...");
         return(new GitCommandLineClient(
                    this.GitExePath,
                    await context.Agent.GetServiceAsync <IRemoteProcessExecuter>().ConfigureAwait(false),
                    await context.Agent.GetServiceAsync <IFileOperationsExecuter>().ConfigureAwait(false),
                    new GitRepositoryInfo(this.RepositoryUrl, this.UserName, this.Password),
                    this,
                    context.CancellationToken
                    ));
     }
     else
     {
         this.LogDebug("No executable path specified, using built-in Git library...");
         return(new RemoteLibGitSharpClient(
                    await context.Agent.TryGetServiceAsync <IRemoteJobExecuter>().ConfigureAwait(false),
                    null,
                    false,
                    context.CancellationToken,
                    new GitRepositoryInfo(this.RepositoryUrl, this.UserName, this.Password),
                    this
                    ));
     }
 }
Example #2
0
        public override async Task <IReadOnlyDictionary <string, RepositoryCommit> > GetCurrentCommitsAsync(IRepositoryMonitorContext context)
        {
            var client = await this.CreateClientAsync(context).ConfigureAwait(false);

            var branches = await client.EnumerateRemoteBranchesAsync().ConfigureAwait(false);

            var results = new Dictionary <string, RepositoryCommit>();

            foreach (var b in branches)
            {
                results[b.Name] = new GitRepositoryCommit {
                    Hash = b.CommitHash
                }
            }
            ;

            return(results);
        }