public async Task <ActionResult <PostCommentResponseBody> > PostComment(
            string owner,
            string repository,
            string pullRequestId,
            [FromBody] PostCommentRequestBody requestBody)
        {
            var commentId    = _guidGenerator.GenerateString();
            var repositoryId = new RepositoryId(owner, repository);
            var command      = new AddSingleComment
                               (
                pullRequestId: pullRequestId,
                repositoryId: repositoryId.ToString(),
                commentId: commentId,
                author: requestBody.Author,
                text: requestBody.Text
                               );

            var streamName = new PullRequestCommentStreamName(commentId).ToString();
            await _applicationService.ExecuteAsync(streamName, history => _comments.AddSingleComment(history, command));

            return(Created(
                       $"repositories/{repositoryId}/pulls/{pullRequestId}/comments",
                       new PostCommentResponseBody {
                CommentId = commentId
            }
                       ));
        }
コード例 #2
0
        public void DeleteRepository()
        {
            SQLiteHelper oSQLHelper = new SQLiteHelper(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, null);

            if (!oSQLHelper.InitConnection())
            {
                return;
            }

            //Count repositories
            oSQLHelper.SetCommandText("DELETE FROM VFile WHERE Fk_Repository = " + this.RepositoryId);
            oSQLHelper.ExecuteNonQuery();

            oSQLHelper.SetCommandText("DELETE FROM VFolder WHERE Fk_Repository = " + this.RepositoryId);
            oSQLHelper.ExecuteNonQuery();

            oSQLHelper.SetCommandText("DELETE FROM Repository WHERE Id_Repository = " + this.RepositoryId);
            oSQLHelper.ExecuteNonQuery();

            oSQLHelper.Dispose();

            if (RepositoryDeleted != null)
            {
                RepositoryDeleted(this, RepositoryId.ToString());
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (Name != null)
                {
                    hashCode = hashCode * 59 + Name.GetHashCode();
                }

                hashCode = hashCode * 59 + Type.GetHashCode();
                if (RepositoryId != null)
                {
                    hashCode = hashCode * 59 + RepositoryId.GetHashCode();
                }
                if (Branch != null)
                {
                    hashCode = hashCode * 59 + Branch.GetHashCode();
                }
                if (EnvironmentId != null)
                {
                    hashCode = hashCode * 59 + EnvironmentId.GetHashCode();
                }
                return(hashCode);
            }
        }
コード例 #4
0
        private void LoadMetadataFromSourceFolder()
        {
            RepositoryId repoId      = new RepositoryId(SourceFolder);
            var          allMetadata = dataManager.GetAllMetadataAsync(repoId).Result;

            MetastockMetadata = new ObservableCollection <SecurityMetadata>(allMetadata);
        }
コード例 #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (RepositoryId.Length != 0)
            {
                hash ^= RepositoryId.GetHashCode();
            }
            if (Description.Length != 0)
            {
                hash ^= Description.GetHashCode();
            }
            if (Status != global::Yandex.Cloud.Containerregistry.V1.LifecyclePolicy.Types.Status.Unspecified)
            {
                hash ^= Status.GetHashCode();
            }
            if (createdAt_ != null)
            {
                hash ^= CreatedAt.GetHashCode();
            }
            hash ^= rules_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #6
0
        /// <summary>
        /// Returns true if RepositoryBranch instances are equal
        /// </summary>
        /// <param name="other">Instance of RepositoryBranch to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(RepositoryBranch other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ProgramId == other.ProgramId ||
                     ProgramId != null &&
                     ProgramId.Equals(other.ProgramId)
                     ) &&
                 (
                     RepositoryId == other.RepositoryId ||

                     RepositoryId.Equals(other.RepositoryId)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     Links == other.Links ||
                     Links != null &&
                     Links.Equals(other.Links)
                 ));
        }
コード例 #7
0
        /// <summary>
        /// Serves as a hash function for a particular type.
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"/>.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        public override int GetHashCode()
        {
            int cName = ConnectorName == null ? 0 : ConnectorName.GetHashCode();
            int rUri  = RepositoryUri == null ? 0 : RepositoryUri.GetHashCode();
            int rId   = RepositoryId == null ? 0 : RepositoryId.GetHashCode();

            return(cName ^ rUri ^ rId);
        }
コード例 #8
0
ファイル: ContentStore.cs プロジェクト: moayyaed/cms-2
 public void Save()
 {
     System.IO.File.WriteAllText(RepositoryId.ToString() + ".json", JsonConvert.SerializeObject(this, new JsonSerializerSettings()
     {
         TypeNameHandling = TypeNameHandling.Auto,
         Formatting       = Formatting.Indented
     }));
 }
コード例 #9
0
ファイル: TestRepositoryId.cs プロジェクト: bbriggs/wesay
		public override int CompareTo(RepositoryId other)
		{
			TestRepositoryId otherAsMy = other as TestRepositoryId;
			if (otherAsMy == null)
			{
				return 1;
			}
			return Comparer<int>.Default.Compare(id, otherAsMy.id);
		}
コード例 #10
0
ファイル: TestRepositoryId.cs プロジェクト: bbriggs/wesay
		public override bool Equals(RepositoryId other)
		{
			TestRepositoryId otherAsMy = other as TestRepositoryId;
			if (otherAsMy == null)
			{
				return false;
			}
			return id == otherAsMy.id;
		}
コード例 #11
0
        public override int CompareTo(RepositoryId other)
        {
            var otherAsMy = other as TestRepositoryId;

            if (otherAsMy == null)
            {
                return(1);
            }
            return(Comparer <int> .Default.Compare(id, otherAsMy.id));
        }
コード例 #12
0
        public override bool Equals(RepositoryId other)
        {
            var otherAsMy = other as TestRepositoryId;

            if (otherAsMy == null)
            {
                return(false);
            }
            return(id == otherAsMy.id);
        }
コード例 #13
0
ファイル: Delete.cs プロジェクト: tomlm/iciclecreek.bot
        /// <inheritdoc/>
        protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (RepositoryId != null && InvitationId != null)
            {
                var repositoryIdValue = RepositoryId.GetValue(dc.State);
                var invitationIdValue = InvitationId.GetValue(dc.State);
                return(await gitHubClient.Repository.Invitation.Delete((Int64)repositoryIdValue, (Int32)invitationIdValue).ConfigureAwait(false));
            }

            throw new ArgumentNullException("Required [repositoryId,invitationId] arguments missing for GitHubClient.Repository.Invitation.Delete");
        }
コード例 #14
0
        public IEnumerable <SecurityDataAndMetadata> ParseSourceQuotes()
        {
            string                  repo        = _sourceMetaLoader.LoadSourceInstrumentMetadata().RepositoryPath;
            string                  symbol      = _sourceMetaLoader.LoadSourceInstrumentMetadata().Symbol;
            RepositoryId            repoId      = new RepositoryId(repo);
            SecurityId              securityId  = new SecurityId(symbol, Interval.Daily, repoId);
            int                     range       = _sourceMetaLoader.LoadSourceInstrumentMetadata().Range;
            SecurityDataAndMetadata dataRecords = dataManager.GetDataAndMetadataAsync(securityId, RequestRange.LastNPoints(range)).Result;

            yield return(dataRecords);
        }
コード例 #15
0
        /// <inheritdoc/>
        protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (RepositoryId != null && NewProject != null)
            {
                var repositoryIdValue = RepositoryId.GetValue(dc.State);
                var newProjectValue   = NewProject.GetValue(dc.State);
                return(await gitHubClient.Repository.Project.CreateForRepository((Int64)repositoryIdValue, newProjectValue).ConfigureAwait(false));
            }

            throw new ArgumentNullException("Required [repositoryId,newProject] arguments missing for GitHubClient.Repository.Project.CreateForRepository");
        }
コード例 #16
0
        public void DeleteItem(RepositoryId repositoryId)
        {
            var args = new EntryEventArgs(repositoryId);

            _caches.DeleteItemFromCaches(repositoryId);
            _decoratedDataMapper.DeleteItem(repositoryId);

            if (AfterEntryDeleted != null)
            {
                AfterEntryDeleted(this, args);
            }
        }
コード例 #17
0
 public void DeleteItem(RepositoryId id)
 {
     if (id == null)
     {
         throw new ArgumentNullException("id");
     }
     if (!_primarySecondaryMap.ContainsKey(id))
     {
         throw new ArgumentOutOfRangeException("id", "Item does not exist in repository");
     }
     _secondary.DeleteItem(_primarySecondaryMap[id]);
     _primary.DeleteItem(id);
     _primarySecondaryMap.Remove(id);
 }
コード例 #18
0
        private async Task <Result <SourcePackageFile[]> > Scan(RepositoryId repo)
        {
            try
            {
                var client   = GetClient();
                var contents = await GetContentsRecursive(client, repo);

                return(contents
                       .Select(c => new SourcePackageFile(c.Path.Contains("/") ? c.Path.Substring(0, c.Path.LastIndexOf("/")) : "<root>", c.Name, Encoding.UTF8.GetBytes(c.Content)))
                       .ToArray());
            }
            catch (NotFoundException nfe) when(nfe.Message == $"repos/{repo}/commits was not found.")
            {
                return(Result <SourcePackageFile[]> .Failed($"{repo} does not exist or is not publically accessible"));
            }
        }
コード例 #19
0
        private async Task<Result<SourcePackageFile[]>> Scan(RepositoryId repo)
        {
            try
            {
                var client = GetClient();
                var contents = await GetContentsRecursive(client, repo);

                return contents
                    .Select(c => new SourcePackageFile(c.Path.Contains("/") ? c.Path.Substring(0, c.Path.LastIndexOf("/")) : "<root>", c.Name, Encoding.UTF8.GetBytes(c.Content)))
                    .ToArray();
            }
            catch (NotFoundException nfe) when (nfe.Message == $"repos/{repo}/commits was not found.")
            {
                return Result<SourcePackageFile[]>.Failed($"{repo} does not exist or is not publically accessible");
            }
        }
コード例 #20
0
        public async Task <Result <SourcePackageFile[]> > Scan(string repoId)
        {
            try
            {
                var repo = RepositoryId.Parse(repoId);
                if (repo.None)
                {
                    return(Result <SourcePackageFile[]> .Failed($"{repoId} is not recognised as a GitHub repository name"));
                }

                return(await Scan(repo.Value));
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Exception scanning repository {name}", repoId);
                return(Result <SourcePackageFile[]> .Failed($"Something didn't go quite right. The error has been logged."));
            }
        }
コード例 #21
0
        /// <summary>
        /// Returns true if PipelinePhase instances are equal
        /// </summary>
        /// <param name="other">Instance of PipelinePhase to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(PipelinePhase other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Type == other.Type ||

                     Type.Equals(other.Type)
                 ) &&
                 (
                     RepositoryId == other.RepositoryId ||
                     RepositoryId != null &&
                     RepositoryId.Equals(other.RepositoryId)
                 ) &&
                 (
                     Branch == other.Branch ||
                     Branch != null &&
                     Branch.Equals(other.Branch)
                 ) &&
                 (
                     EnvironmentId == other.EnvironmentId ||
                     EnvironmentId != null &&
                     EnvironmentId.Equals(other.EnvironmentId)
                 ));
        }
        public async Task PostCommentShouldResultsWithSingleCommentWasAdded()
        {
            //Given
            var randomOwner      = _guidGenerator.GenerateString();
            var randomRepository = _guidGenerator.GenerateString();
            var repositoryId     = new RepositoryId(randomOwner, randomRepository);
            var pullRequestId    = _guidGenerator.GenerateString();

            //When
            var postRequest = new
            {
                Url  = $"/rest-api/{randomOwner}/{randomRepository}/pulls/{pullRequestId}/comments",
                Body = new
                {
                    Text   = "Comment text",
                    Author = "LoggedUser"
                }
            };
            var response = await _client.PostAsync(postRequest.Url, postRequest.Body.ToJson());

            //Then
            var responseBody =
                JsonConvert.DeserializeObject <PostCommentResponseBody>(await response.Content.ReadAsStringAsync());
            var expectedStreamName = $"PullRequestComment-{responseBody.CommentId}";
            var streamLastEvent    = await _eventStore.StreamLastEvent(expectedStreamName, _eventSerializer);

            streamLastEvent.Should().BeEquivalentTo(
                new SingleCommentWasAdded
                (
                    pullRequestId: pullRequestId,
                    repositoryId: repositoryId.ToString(),
                    commentId: responseBody.CommentId,
                    author: "LoggedUser",
                    text: "Comment text",
                    occurredAt: _clock.Now
                )
                );
        }
コード例 #23
0
        public async Task UpdatePullRequestCommentsReadModelWhenSingleCommentWasAdded()
        {
            //When
            var randomOwner = _guidGenerator.GenerateString();
            var randomRepository = _guidGenerator.GenerateString();
            var repositoryId = new RepositoryId(randomOwner, randomRepository);
            var pullRequestId = _guidGenerator.GenerateString();
            var commentId = _guidGenerator.GenerateString();
            var singleCommentWasAdded = new SingleCommentWasAdded
            {
                OccurredAt = DateTime.UtcNow,
                PullRequestId = pullRequestId,
                RepositoryId = repositoryId.ToString(),
                CommentId = commentId,
                Author = "LoggedUser",
                Text = "Comment text"
            };

            var streamName = $"PullRequestComment-{commentId}";
            await _eventStore.Publish(streamName, singleCommentWasAdded, _eventSerializer);

            //Then
            var getUrl = $"/rest-api/{randomOwner}/{randomRepository}/pulls/{pullRequestId}/comments";
            await AssertionHelper.WaitUntil(async () => (await GetPullRequestComments(getUrl)).Comments.Count > 0);
            var responseBody = await GetPullRequestComments(getUrl);
            responseBody.Comments.Should().HaveCount(1);
            responseBody.Comments.Should().HaveElementAt(
                0,
                new PullRequestComment
                {
                    Author = "LoggedUser",
                    CommentId = commentId,
                    PostedAt = singleCommentWasAdded.OccurredAt,
                    PullRequestId = pullRequestId,
                    Text = "Comment text"
                }
            );
        }
コード例 #24
0
        private async Task<IReadOnlyList<RepositoryContent>> GetContentsRecursive(GitHubClient client, RepositoryId repo)
        {
            var commits = await client.Repository.Commit.GetAll(repo.Owner, repo.Name);
            var head = commits.First();
            var treeResponse = await client.Git.Tree.GetRecursive(repo.Owner, repo.Name, head.Sha);

            if (treeResponse.Truncated)
                Log.Warning("Result truncated for {repo}", repo);

            var getFileTasks = treeResponse.Tree
                .Where(t => t.Type == TreeType.Blob)
                .Where(t => SourcePackageFileReader.SupportedFiles.Any(
                        f => t.Path.Equals(f, StringComparison.OrdinalIgnoreCase) || 
                        t.Path.EndsWith($"/{f}", StringComparison.OrdinalIgnoreCase))
                )
                .Select(t => client.Repository.Content.GetAllContents(repo.Owner, repo.Name, t.Path))
                .ToArray();

            return (await Task.WhenAll(getFileTasks))
                .SelectMany(r => r)
                .ToArray();

        }
コード例 #25
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (ProgramId != null)
                {
                    hashCode = hashCode * 59 + ProgramId.GetHashCode();
                }

                hashCode = hashCode * 59 + RepositoryId.GetHashCode();
                if (Name != null)
                {
                    hashCode = hashCode * 59 + Name.GetHashCode();
                }
                if (Links != null)
                {
                    hashCode = hashCode * 59 + Links.GetHashCode();
                }
                return(hashCode);
            }
        }
コード例 #26
0
        /// <summary>
        /// Perform per-request authentication processing.
        /// </summary>
        /// <param name="channel">The channel object</param>
        /// <param name="client">The web client that is about to be used to execute the request.  It can't be used by the authentication provider to make requests.</param>
        /// <param name="request">The request that is about to be sent</param>
        /// <param name="resourceUrl">The resource URL (with query string) specified by the client.</param>
        /// <param name="requestSupportsAuthentication">Indicates if the request being processed supports authentication or not.</param>
        /// <remarks>If the request doesn't support authentication, it's a best practice to not provide any authentication information.</remarks>
        void IWebAuthenticationProvider.PreProcessRequest(WebChannel channel, HttpClient client, HttpRequestMessage request, string resourceUrl, bool requestSupportsAuthentication)
        {
            //figure out the effective relative URL.
            string fullUrl = resourceUrl;

            if (client.BaseAddress != null)
            {
                fullUrl = client.BaseAddress + resourceUrl;
            }

            var clientUri = new Uri(fullUrl);

            //we're doing sets not adds to make sure we overwrite any existing value.
            if (requestSupportsAuthentication)
            {
                request.Headers.TryAddWithoutValidation(AuthorizationHeader, AuthorizationPrefix + ": " + CalculateHash(clientUri.PathAndQuery));
                request.Headers.Add(ClientRepositoryHeader, RepositoryId.ToString());
            }
            else
            {
                //remove our repository header.
                request.Headers.Remove(ClientRepositoryHeader);
            }
        }
コード例 #27
0
 public void DeleteItem(RepositoryId id)
 {
     throw new NotImplementedException();
 }
コード例 #28
0
 private void CreateInitialItem()
 {
     this.item = DataMapperUnderTest.CreateItem();
     this.id   = DataMapperUnderTest.GetId(this.item);
 }
コード例 #29
0
 private void CreateItemToTest()
 {
     this.item = DataMapperUnderTest.CreateItem();
     this.id   = DataMapperUnderTest.GetId(Item);
 }
コード例 #30
0
 private void CreateInitialItem()
 {
     item = DataMapperUnderTest.CreateItem();
     id   = DataMapperUnderTest.GetId(Item);
 }
コード例 #31
0
 public void SetState()
 {
     RepositoryId[] idsFrompersistedData = DataMapperUnderTest.GetAllItems();
     Id   = idsFrompersistedData[0];
     Item = DataMapperUnderTest.GetItem(Id);
 }
コード例 #32
0
 public void SetState()
 {
     Item = DataMapperUnderTest.CreateItem();
     Id   = DataMapperUnderTest.GetId(Item);
 }
コード例 #33
0
ファイル: Db4oRepositoryId.cs プロジェクト: bbriggs/wesay
		public override int CompareTo(RepositoryId other)
		{
			return CompareTo(other as Db4oRepositoryId);
		}
コード例 #34
0
ファイル: Account.cs プロジェクト: gabrielgreen/Gera
        /// <summary>
        /// Removes the Repository having the given RepositoryId.
        /// </summary>
        /// <param name="RepositoryId">An RepositoryId.</param>
        public Boolean RemoveRepository(RepositoryId RepositoryId)
        {
            if (RepositoryId != null)
                return _Repositories.Remove(RepositoryId);

            return false;
        }
コード例 #35
0
ファイル: Repository.cs プロジェクト: gabrielgreen/Gera
 /// <summary>
 /// Create a new Gera repository.
 /// </summary>
 /// <param name="RepositoryId">The RepositoryId.</param>
 public Repository(RepositoryId RepositoryId)
 {
     Id      = RepositoryId;
     _Graphs = new Dictionary<GraphId, GeraGraph>();
 }
コード例 #36
0
ファイル: Account.cs プロジェクト: gabrielgreen/Gera
        /// <summary>
        /// Create a new repository using the given RepositoryId.
        /// </summary>
        /// <param name="RepositoryId">An optional RepositoryId.</param>
        /// <param name="Repository">A optional Repository.</param>
        public IRepository CreateRepository(RepositoryId RepositoryId = null, IRepository Repository = null)
        {
            if (RepositoryId == null)
                RepositoryId = RepositoryId.NewRepositoryId;

            if (Repository   == null)
                Repository   = new Repository(RepositoryId: RepositoryId);

            _Repositories.Add(RepositoryId, Repository);

            return Repository;
        }
コード例 #37
0
ファイル: Account.cs プロジェクト: gabrielgreen/Gera
        /// <summary>
        /// Checks if a Repository having the given RepositoryId already exists.
        /// </summary>
        /// <param name="RepositoryId">An RepositoryId.</param>
        public Boolean HasRepository(RepositoryId RepositoryId)
        {
            if (RepositoryId != null)
                return _Repositories.ContainsKey(RepositoryId);

            return false;
        }
コード例 #38
0
ファイル: Db4oRepositoryId.cs プロジェクト: bbriggs/wesay
		public override bool Equals(RepositoryId other)
		{
			return Equals(other as Db4oRepositoryId);
		}
コード例 #39
0
 public override int CompareTo(RepositoryId other)
 {
     return(0);
 }
コード例 #40
0
 public override bool Equals(RepositoryId other)
 {
     return(true);
 }
コード例 #41
0
ファイル: Account.cs プロジェクト: gabrielgreen/Gera
        /// <summary>
        /// Return a specific repository.
        /// </summary>
        /// <param name="RepositoryId">The RepositoryId.</param>
        /// <param name="Repository">The Repository.</param>
        public Boolean TryGetRepository(RepositoryId RepositoryId, out IRepository Repository)
        {
            if (RepositoryId != null)
                return _Repositories.TryGetValue(RepositoryId, out Repository);

            Repository = null;
            return false;
        }