@ -231,46 +231,46 @@ func (issue *Issue) verifyReferencedIssue(stdCtx context.Context, ctx *crossRefe
}
// AddCrossReferences add cross references
func ( c omment * Comment ) AddCrossReferences ( stdCtx context . Context , doer * user_model . User , removeOld bool ) error {
if c omment . Type != CommentTypeCode && c omment . Type != CommentTypeComment {
func ( c * Comment ) AddCrossReferences ( stdCtx context . Context , doer * user_model . User , removeOld bool ) error {
if c . Type != CommentTypeCode && c . Type != CommentTypeComment {
return nil
}
if err := c omment . LoadIssueCtx ( stdCtx ) ; err != nil {
if err := c . LoadIssueCtx ( stdCtx ) ; err != nil {
return err
}
ctx := & crossReferencesContext {
Type : CommentTypeCommentRef ,
Doer : doer ,
OrigIssue : c omment . Issue ,
OrigComment : c omment ,
OrigIssue : c . Issue ,
OrigComment : c ,
RemoveOld : removeOld ,
}
return c omment . Issue . createCrossReferences ( stdCtx , ctx , "" , c omment . Content )
return c . Issue . createCrossReferences ( stdCtx , ctx , "" , c . Content )
}
func ( c omment * Comment ) neuterCrossReferences ( ctx context . Context ) error {
return neuterCrossReferences ( ctx , c omment . IssueID , c omment . ID )
func ( c * Comment ) neuterCrossReferences ( ctx context . Context ) error {
return neuterCrossReferences ( ctx , c . IssueID , c . ID )
}
// LoadRefComment loads comment that created this reference from database
func ( c omment * Comment ) LoadRefComment ( ) ( err error ) {
if c omment . RefComment != nil {
func ( c * Comment ) LoadRefComment ( ) ( err error ) {
if c . RefComment != nil {
return nil
}
c omment . RefComment , err = GetCommentByID ( db . DefaultContext , c omment . RefCommentID )
return
c . RefComment , err = GetCommentByID ( db . DefaultContext , c . RefCommentID )
return err
}
// LoadRefIssue loads comment that created this reference from database
func ( c omment * Comment ) LoadRefIssue ( ) ( err error ) {
if c omment . RefIssue != nil {
func ( c * Comment ) LoadRefIssue ( ) ( err error ) {
if c . RefIssue != nil {
return nil
}
c omment . RefIssue , err = GetIssueByID ( db . DefaultContext , c omment . RefIssueID )
c . RefIssue , err = GetIssueByID ( db . DefaultContext , c . RefIssueID )
if err == nil {
err = c omment . RefIssue . LoadRepo ( db . DefaultContext )
err = c . RefIssue . LoadRepo ( db . DefaultContext )
}
return
return err
}
// CommentTypeIsRef returns true if CommentType is a reference from another issue
@ -279,44 +279,44 @@ func CommentTypeIsRef(t CommentType) bool {
}
// RefCommentHTMLURL returns the HTML URL for the comment that created this reference
func ( c omment * Comment ) RefCommentHTMLURL ( ) string {
func ( c * Comment ) RefCommentHTMLURL ( ) string {
// Edge case for when the reference is inside the title or the description of the referring issue
if c omment . RefCommentID == 0 {
return c omment . RefIssueHTMLURL ( )
if c . RefCommentID == 0 {
return c . RefIssueHTMLURL ( )
}
if err := c omment . LoadRefComment ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefComment(%d): %v" , c omment . RefCommentID , err )
if err := c . LoadRefComment ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefComment(%d): %v" , c . RefCommentID , err )
return ""
}
return c omment . RefComment . HTMLURL ( )
return c . RefComment . HTMLURL ( )
}
// RefIssueHTMLURL returns the HTML URL of the issue where this reference was created
func ( c omment * Comment ) RefIssueHTMLURL ( ) string {
if err := c omment . LoadRefIssue ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefIssue(%d): %v" , c omment . RefCommentID , err )
func ( c * Comment ) RefIssueHTMLURL ( ) string {
if err := c . LoadRefIssue ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefIssue(%d): %v" , c . RefCommentID , err )
return ""
}
return c omment . RefIssue . HTMLURL ( )
return c . RefIssue . HTMLURL ( )
}
// RefIssueTitle returns the title of the issue where this reference was created
func ( c omment * Comment ) RefIssueTitle ( ) string {
if err := c omment . LoadRefIssue ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefIssue(%d): %v" , c omment . RefCommentID , err )
func ( c * Comment ) RefIssueTitle ( ) string {
if err := c . LoadRefIssue ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefIssue(%d): %v" , c . RefCommentID , err )
return ""
}
return c omment . RefIssue . Title
return c . RefIssue . Title
}
// RefIssueIdent returns the user friendly identity (e.g. "#1234") of the issue where this reference was created
func ( c omment * Comment ) RefIssueIdent ( ) string {
if err := c omment . LoadRefIssue ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefIssue(%d): %v" , c omment . RefCommentID , err )
func ( c * Comment ) RefIssueIdent ( ) string {
if err := c . LoadRefIssue ( ) ; err != nil { // Silently dropping errors :unamused:
log . Error ( "LoadRefIssue(%d): %v" , c . RefCommentID , err )
return ""
}
// FIXME: check this name for cross-repository references (#7901 if it gets merged)
return fmt . Sprintf ( "#%d" , c omment . RefIssue . Index )
return fmt . Sprintf ( "#%d" , c . RefIssue . Index )
}
// __________ .__ .__ __________ __