예제 #1
0
        /// <summary>
        /// Processes a push message by copying files from Git to a destination repository.
        /// Reports any errors and successfully copied files.
        /// </summary>
        /// <param name="data">The deserialized push message</param>
        /// <returns></returns>
        public async Task<IHttpActionResult> PostAsync(VSOCodePushed data, CancellationToken token)
        {
            _parameters = new HeaderParameters(Request.Headers,
                HEADER_ROOT,
                HEADER_SOURCE_CONNECTIONSTRING,
                HEADER_DESTINATION_CONNECTIONSTRING);

            if (!_parameters.AnyMissing)
            {
                var request = JsonConvert.SerializeObject(data, Formatting.Indented);
                _errorReport.Request = request;
                _changesReport.Request = request;

                _pushEvent = data;
                _token = token;

                var result = await HandleSynchronizePushAsync();
                await SendExceptionReportAsync();
                await SendChangesReportAsync();
                return result;
            }
            else
            {
                return BadRequest("Missing headers");
            }
        }
 private static VSOCodePushed CreateVSOCodePushedRequest(string commitId, string commitDate)
 {
     var push = new VSOCodePushed()
     {
         Resource = new GitPush()
         {
             Commits = new GitCommit[]
             {
                 new GitCommit()
                 {
                     CommitId = commitId,
                     Committer = new GitUserDate()
                     {
                         Date = DateTime.ParseExact(commitDate, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture),
                         Email = "*****@*****.**"
                     }
                 }
             },
             Repository = new GitRepository() { Id = new Guid("0ad49569-db8b-4a8a-b5cc-f7ff009949c8") }
         }
     };
     return push;
 }