Skip to content
This repository was archived by the owner on Jul 2, 2022. It is now read-only.

Commit 71ede5f

Browse files
committed
Prevent Edit For Files Not Capable Of Being Pushed
1 parent 9763738 commit 71ede5f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
*.suo
44
*.userprefs
55
packages
6-
Components/
6+
.vs

CodeHub.iOS/ViewControllers/Source/FileSourceViewController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ private async Task Load(CancellationToken cancelToken)
139139
Content = items.First();
140140
}
141141

142+
var repo = await _applicationService
143+
.GitHubClient.Repository.Get(_username, _repository);
144+
142145
var fileName = System.IO.Path.GetFileName(Content.Name);
143146
ContentSavePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), fileName);
144147

@@ -149,12 +152,11 @@ private async Task Load(CancellationToken cancelToken)
149152
var isBinary = _forceBinary || !mime.Contains("charset");
150153
if (isBinary)
151154
{
152-
CanEdit = false;
153155
LoadFile(ContentSavePath);
154156
}
155157
else
156158
{
157-
CanEdit = _shaType == ShaType.Branch;
159+
CanEdit = repo.Permissions.Push && _shaType == ShaType.Branch;
158160
await LoadSource(new Uri("file://" + ContentSavePath), _isMarkdown);
159161
}
160162
}

0 commit comments

Comments
 (0)