@@ -1791,6 +1791,7 @@ func ViewIssue(ctx *context.Context) {
1791
1791
pull .Issue = issue
1792
1792
canDelete := false
1793
1793
allowMerge := false
1794
+ canWriteToHeadRepo := false
1794
1795
1795
1796
if ctx .IsSigned {
1796
1797
if err := pull .LoadHeadRepo (ctx ); err != nil {
@@ -1811,7 +1812,7 @@ func ViewIssue(ctx *context.Context) {
1811
1812
ctx .Data ["DeleteBranchLink" ] = issue .Link () + "/cleanup"
1812
1813
}
1813
1814
}
1814
- ctx . Data [ "CanWriteToHeadRepo" ] = true
1815
+ canWriteToHeadRepo = true
1815
1816
}
1816
1817
}
1817
1818
@@ -1823,6 +1824,9 @@ func ViewIssue(ctx *context.Context) {
1823
1824
ctx .ServerError ("GetUserRepoPermission" , err )
1824
1825
return
1825
1826
}
1827
+ if ! canWriteToHeadRepo { // maintainers maybe allowed to push to head repo even if they can't write to it
1828
+ canWriteToHeadRepo = pull .AllowMaintainerEdit && perm .CanWrite (unit .TypeCode )
1829
+ }
1826
1830
allowMerge , err = pull_service .IsUserAllowedToMerge (ctx , pull , perm , ctx .Doer )
1827
1831
if err != nil {
1828
1832
ctx .ServerError ("IsUserAllowedToMerge" , err )
@@ -1835,6 +1839,8 @@ func ViewIssue(ctx *context.Context) {
1835
1839
}
1836
1840
}
1837
1841
1842
+ ctx .Data ["CanWriteToHeadRepo" ] = canWriteToHeadRepo
1843
+ ctx .Data ["ShowMergeInstructions" ] = canWriteToHeadRepo
1838
1844
ctx .Data ["AllowMerge" ] = allowMerge
1839
1845
1840
1846
prUnit , err := repo .GetUnit (ctx , unit .TypePullRequests )
@@ -1889,13 +1895,9 @@ func ViewIssue(ctx *context.Context) {
1889
1895
ctx .ServerError ("LoadProtectedBranch" , err )
1890
1896
return
1891
1897
}
1892
- ctx . Data [ "ShowMergeInstructions" ] = true
1898
+
1893
1899
if pb != nil {
1894
1900
pb .Repo = pull .BaseRepo
1895
- var showMergeInstructions bool
1896
- if ctx .Doer != nil {
1897
- showMergeInstructions = pb .CanUserPush (ctx , ctx .Doer )
1898
- }
1899
1901
ctx .Data ["ProtectedBranch" ] = pb
1900
1902
ctx .Data ["IsBlockedByApprovals" ] = ! issues_model .HasEnoughApprovals (ctx , pb , pull )
1901
1903
ctx .Data ["IsBlockedByRejection" ] = issues_model .MergeBlockedByRejectedReview (ctx , pb , pull )
@@ -1906,7 +1908,6 @@ func ViewIssue(ctx *context.Context) {
1906
1908
ctx .Data ["ChangedProtectedFiles" ] = pull .ChangedProtectedFiles
1907
1909
ctx .Data ["IsBlockedByChangedProtectedFiles" ] = len (pull .ChangedProtectedFiles ) != 0
1908
1910
ctx .Data ["ChangedProtectedFilesNum" ] = len (pull .ChangedProtectedFiles )
1909
- ctx .Data ["ShowMergeInstructions" ] = showMergeInstructions
1910
1911
}
1911
1912
ctx .Data ["WillSign" ] = false
1912
1913
if ctx .Doer != nil {
0 commit comments