@@ -1229,7 +1229,7 @@ func NewIssuePost(ctx *context.Context) {
1229
1229
}
1230
1230
1231
1231
// roleDescriptor returns the Role Descriptor for a comment in/with the given repo, poster and issue
1232
- func roleDescriptor (ctx stdCtx.Context , repo * repo_model.Repository , poster * user_model.User , issue * issues_model.Issue , gitRepo * git. Repository , hasOriginalAuthor bool ) (issues_model.RoleDescriptor , error ) {
1232
+ func roleDescriptor (ctx stdCtx.Context , repo * repo_model.Repository , poster * user_model.User , issue * issues_model.Issue , hasOriginalAuthor bool ) (issues_model.RoleDescriptor , error ) {
1233
1233
if hasOriginalAuthor {
1234
1234
return issues_model .RoleDescriptorNone , nil
1235
1235
}
@@ -1287,15 +1287,21 @@ func roleDescriptor(ctx stdCtx.Context, repo *repo_model.Repository, poster *use
1287
1287
return roleDescriptor , nil
1288
1288
}
1289
1289
1290
- if commits , err := gitRepo .SearchCommits (git.SearchCommitsOptions {
1291
- Authors : []string {poster .Name },
1292
- All : true ,
1293
- Limit : 2 ,
1294
- }); err != nil {
1290
+ // If the poster is the contributor of the repo
1291
+ searchOpt := & issue_indexer.SearchOptions {
1292
+ Paginator : & db.ListOptions {
1293
+ Page : 1 ,
1294
+ PageSize : 2 ,
1295
+ },
1296
+ RepoIDs : []int64 {repo .ID },
1297
+ IsPull : util .OptionalBoolTrue ,
1298
+ PosterID : & poster .ID ,
1299
+ }
1300
+ if _ , total , err := issue_indexer .SearchIssues (ctx , searchOpt ); err != nil {
1295
1301
return issues_model .RoleDescriptorNone , err
1296
- } else if len ( commits ) == 1 {
1302
+ } else if total == 1 {
1297
1303
roleDescriptor = roleDescriptor .WithRole (issues_model .RoleDescriptorFirstTimeContributor )
1298
- } else if len ( commits ) > 1 {
1304
+ } else if total > 1 {
1299
1305
roleDescriptor = roleDescriptor .WithRole (issues_model .RoleDescriptorContributor )
1300
1306
}
1301
1307
@@ -1554,7 +1560,7 @@ func ViewIssue(ctx *context.Context) {
1554
1560
// check if dependencies can be created across repositories
1555
1561
ctx .Data ["AllowCrossRepositoryDependencies" ] = setting .Service .AllowCrossRepositoryDependencies
1556
1562
1557
- if issue .ShowRole , err = roleDescriptor (ctx , repo , issue .Poster , issue , ctx . Repo . GitRepo , issue .HasOriginalAuthor ()); err != nil {
1563
+ if issue .ShowRole , err = roleDescriptor (ctx , repo , issue .Poster , issue , issue .HasOriginalAuthor ()); err != nil {
1558
1564
ctx .ServerError ("roleDescriptor" , err )
1559
1565
return
1560
1566
}
@@ -1593,7 +1599,7 @@ func ViewIssue(ctx *context.Context) {
1593
1599
continue
1594
1600
}
1595
1601
1596
- comment .ShowRole , err = roleDescriptor (ctx , repo , comment .Poster , issue , ctx . Repo . GitRepo , comment .HasOriginalAuthor ())
1602
+ comment .ShowRole , err = roleDescriptor (ctx , repo , comment .Poster , issue , comment .HasOriginalAuthor ())
1597
1603
if err != nil {
1598
1604
ctx .ServerError ("roleDescriptor" , err )
1599
1605
return
@@ -1692,7 +1698,7 @@ func ViewIssue(ctx *context.Context) {
1692
1698
continue
1693
1699
}
1694
1700
1695
- c .ShowRole , err = roleDescriptor (ctx , repo , c .Poster , issue , ctx . Repo . GitRepo , c .HasOriginalAuthor ())
1701
+ c .ShowRole , err = roleDescriptor (ctx , repo , c .Poster , issue , c .HasOriginalAuthor ())
1696
1702
if err != nil {
1697
1703
ctx .ServerError ("roleDescriptor" , err )
1698
1704
return
0 commit comments