// Updates a comment on a commit
//
// https://developer.github.com/v3/repos/comments/#update-a-commit-comment
498370
func (c *CommitCommentsService) Update(uri *Hyperlink, uriParams M, requestParams interface{}) (comment *CommitComment, result *Result) {
	url, err := ExpandWithDefault(uri, &RepoCommentsURL, uriParams)
	if err != nil {
		return nil, &Result{Err: err}
	}

	result = c.client.patch(url, requestParams, &comment)
	return
}
400618
func Comments(b bool) option {
	return func(c *sass) error {
		c.ctx.Comments = b
		return nil
	}
}
604659
func (c *CommentsController) Update(ctx *app.UpdateCommentsContext) error {
	identityID, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	cm, wi, userIsCreator, err := c.loadComment(ctx.Context, ctx.CommentID, *identityID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	// User is allowed to update if user is creator of the comment OR user is a space collaborator
	if !userIsCreator {
		authorized, err := authz.Authorize(ctx, wi.SpaceID.String())
		if err != nil {
			return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(err.Error()))
		}
		if !authorized {
			return jsonapi.JSONErrorResponse(ctx, errors.NewForbiddenError("user is not a space collaborator"))
		}
	}
	err = c.performUpdate(ctx, cm, identityID)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	// This code should change if others type of parents than WI are allowed
	res := &app.CommentSingle{
		Data: ConvertComment(ctx.Request, *cm, CommentIncludeParentWorkItem(ctx, cm)),
	}
	c.notification.Send(ctx, notification.NewCommentUpdated(cm.ID.String()))
	return ctx.OK(res)
}
416166
def add_comment(repo: GithubRepository, pull_id: int, text: str) -> None:
    
    url = ("https://api.github.com/repos/{}/{}/issues/{}/comments"
           "?access_token={}".format(repo.organization,
                                     repo.name,
                                     pull_id,
                                     repo.access_token))
    data = {
        'body': text
    }
    response = requests.post(url, json=data)

    if response.status_code != 201:
        raise RuntimeError('Add comment failed. Code: {}. Content: {}.'.format(
            response.status_code, response.content))
565973
func (m *GormCommentRepository) Delete(ctx context.Context, commentID uuid.UUID, suppressorID uuid.UUID) error {
	if commentID == uuid.Nil {
		return errors.NewNotFoundError("comment", commentID.String())
	}
	// fetch the id and parent id of the comment to delete, to store them in the new revision.
	c := Comment{}
	tx := m.db.Select("id, parent_id, parent_comment_id").Where("id = ?", commentID).Find(&c)
	if tx.RowsAffected != 1 {
		return errors.NewNotFoundError("comment", commentID.String())
	}
	if err := tx.Error; err != nil {
		return errors.NewInternalError(ctx, err)
	}
	m.db.Delete(c)
	// save a revision of the deleted comment
	if err := m.revisionRepository.Create(ctx, suppressorID, RevisionTypeDelete, c); err != nil {
		return errs.Wrapf(err, "error while deleting work item")
	}
	return nil
}
109568
func (crs *ConfigRepoService) Update(ctx context.Context, id string, cr *ConfigRepo) (out *ConfigRepo, resp *APIResponse, err error) {
	out = &ConfigRepo{}
	_, resp, err = crs.client.putAction(ctx, &APIClientRequest{
		Path:         fmt.Sprintf("admin/config_repos/%s", id),
		RequestBody:  cr,
		ResponseBody: out,
		APIVersion:   apiV1,
	})

	out.client = crs.client
	return
}
924425
func (c *CommentService) Update(teamName string, commentID int, comment Comment) (*CommentResponse, error) {
	commentIDStr := strconv.Itoa(commentID)
	commentURL := CommnetURL + "/" + teamName + "/comments" + "/" + commentIDStr
	var commentResponse CommentResponse
	var commentReq CommentReq
	commentReq.Comment = comment

	var data []byte
	var err error
	if data, err = json.Marshal(commentReq); err != nil {
		return nil, err
	}

	res, err := c.client.patch(commentURL, "application/json", bytes.NewReader(data), &commentResponse)
	if err != nil {
		return nil, err
	}

	defer res.Body.Close()

	return &commentResponse, nil
}
112459
func UpdateComment(doer *User, c *Comment, oldContent string) (err error) {
	if _, err = x.Id(c.ID).AllCols().Update(c); err != nil {
		return err
	}

	if err = c.Issue.LoadAttributes(); err != nil {
		log.Error(2, "Issue.LoadAttributes [issue_id: %d]: %v", c.IssueID, err)
	} else if err = PrepareWebhooks(c.Issue.Repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{
		Action:  api.HOOK_ISSUE_COMMENT_EDITED,
		Issue:   c.Issue.APIFormat(),
		Comment: c.APIFormat(),
		Changes: &api.ChangesPayload{
			Body: &api.ChangesFromPayload{
				From: oldContent,
			},
		},
		Repository: c.Issue.Repo.APIFormat(nil),
		Sender:     doer.APIFormat(),
	}); err != nil {
		log.Error(2, "PrepareWebhooks [comment_id: %d]: %v", c.ID, err)
	}

	return nil
}
663990
func (u *User) SetComment(comment string) {
	packet := MumbleProto.UserState{
		Session: &u.Session,
		Comment: &comment,
	}
	u.client.Conn.WriteProto(&packet)
}
264467
func (u *updater) Update(status error) {
	u.mu.Lock()
	defer u.mu.Unlock()

	u.status = status
}
764231
func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content string, attachments []string) (*Comment, error) {
	comment, err := CreateComment(&CreateCommentOptions{
		Type:        COMMENT_TYPE_COMMENT,
		Doer:        doer,
		Repo:        repo,
		Issue:       issue,
		Content:     content,
		Attachments: attachments,
	})
	if err != nil {
		return nil, fmt.Errorf("CreateComment: %v", err)
	}

	comment.Issue = issue
	if err = PrepareWebhooks(repo, HOOK_EVENT_ISSUE_COMMENT, &api.IssueCommentPayload{
		Action:     api.HOOK_ISSUE_COMMENT_CREATED,
		Issue:      issue.APIFormat(),
		Comment:    comment.APIFormat(),
		Repository: repo.APIFormat(nil),
		Sender:     doer.APIFormat(),
	}); err != nil {
		log.Error(2, "PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
	}

	return comment, nil
}
210251
func (comment *UserPostComment) Revisions() (modifications []string) {
	Db().Model(UserPostCommentRevision{}).Where(&UserPostCommentRevision{Hcid: comment.Hcid}).Pluck("message", &modifications)
	return
}
1155080
func EditPostComment() echo.HandlerFunc {

	// swagger:route PUT /projects/{id}/posts/{pid}/comments/{cid} project post comment EditProjectPostComment
	//
	// Update the speficied comment on the specified project post
	//
	// Consumes:
	// - application/json
	//
	//	Produces:
	//	- application/json
	//
	//	Security:
	//		oauth: project_comments:write
	//
	//	Responses:
	//		default: ProjectsIdPostsPidCommentsCid

	return func(c echo.Context) error {
		if !rest.IsGranted("project_comments:write", c) {
			return rest.InvalidScopeResponse("project_comments:write", c)
		}

		// Read a rest.Message from the body request.
		message := rest.NewMessage{}
		if err := c.Bind(&message); err != nil {
			return err
		}
		comment := c.Get("comment").(*nerdz.ProjectPostComment)

		// Update filds
		comment.Message = message.Message
		if comment.Lang != "" {
			comment.Lang = message.Lang
		}

		// Edit
		me := c.Get("me").(*nerdz.User)
		if err := me.Edit(comment); err != nil {
			return err
		}

		// Extract the TO from the comment and return selected fields.
		return rest.SelectFields(comment.GetTO(me), c)
	}
}
1355036
func (s *ChangeInfo) SetComment(v string) *ChangeInfo {
	s.Comment = &v
	return s
}
267317
func (r *RepositoryComment) GetUpdatedAt() time.Time {
	if r == nil || r.UpdatedAt == nil {
		return time.Time{}
	}
	return *r.UpdatedAt
}
925831
func (s *State) Update(updater func(up Updatable) error) ([]byte, int64, error) {
	s.Lock()
	defer s.Unlock()
	err := updater(&s.writeState)
	if err != nil {
		return nil, 0, err
	}
	return s.commit()
}
1222314
func UpdateRepoMD(ctx context.Context, config libkbfs.Config,
	tlfHandle *tlfhandle.Handle, fs billy.Filesystem,
	pushType keybase1.GitPushType,
	oldRepoName string, refDataByName RefDataByName) error {
	folder := tlfHandle.ToFavorite().ToKBFolder(false)

	// Get the user-formatted repo name.
	f, err := fs.Open(kbfsConfigName)
	if err != nil {
		return err
	}
	defer f.Close()
	buf, err := ioutil.ReadAll(f)
	if err != nil {
		return err
	}
	c, err := configFromBytes(buf)
	if err != nil {
		return err
	}

	gitRefMetadata := make([]keybase1.GitRefMetadata, 0, len(refDataByName))
	for refName, refData := range refDataByName {
		hasMoreCommits := false
		kbCommits := make([]keybase1.GitCommit, 0, len(refData.Commits))
		for _, c := range refData.Commits {
			if c == CommitSentinelValue {
				// Accept a sentinel value at the end of the commit list that
				// indicates that there would have been more commits, but we
				// stopped due to a cap.
				hasMoreCommits = true
				break
			}
			kbCommits = append(kbCommits, keybase1.GitCommit{
				CommitHash:  hex.EncodeToString(c.Hash[:]),
				Message:     c.Message,
				AuthorName:  c.Author.Name,
				AuthorEmail: c.Author.Email,
				Ctime:       keybase1.Time(c.Author.When.Unix()),
			})
		}
		gitRefMetadata = append(gitRefMetadata, keybase1.GitRefMetadata{
			RefName:              string(refName),
			Commits:              kbCommits,
			MoreCommitsAvailable: hasMoreCommits,
			IsDelete:             refData.IsDelete,
		})
	}
	log := config.MakeLogger("")
	log.CDebugf(ctx, "Putting git MD update")
	err = config.KBPKI().PutGitMetadata(
		ctx, folder, keybase1.RepoID(c.ID.String()),
		keybase1.GitLocalMetadata{
			RepoName:         keybase1.GitRepoName(c.Name),
			Refs:             gitRefMetadata,
			PushType:         pushType,
			PreviousRepoName: keybase1.GitRepoName(oldRepoName),
		})
	if err != nil {
		// Just log the put error, it shouldn't block the success of
		// the overall git operation.
		log.CDebugf(ctx, "Failed to put git metadata: %+v", err)
	}
	return nil
}