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