Commit d701d5869516142a4073804622503299202cfbe2
Exists in
spb-stable
and in
3 other branches
Merge branch 'gitlab_git_rugged' into 'master'
gitlab_git with rugged Updated gitlab_git version with Blob via rugged
Showing
6 changed files
with
20 additions
and
10 deletions
Show diff stats
Gemfile
... | ... | @@ -29,7 +29,7 @@ gem 'omniauth-github' |
29 | 29 | |
30 | 30 | # Extracting information from a git repository |
31 | 31 | # Provide access to Gitlab::Git library |
32 | -gem "gitlab_git", git: 'https://gitlab.com/gitlab-org/gitlab_git.git', ref: '39bc4f043414f1e49f802ed633fa20e6400bfa49' | |
32 | +gem "gitlab_git", git: 'https://gitlab.com/gitlab-org/gitlab_git.git' | |
33 | 33 | |
34 | 34 | # Ruby/Rack Git Smart-HTTP Server Handler |
35 | 35 | gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' | ... | ... |
Gemfile.lock
... | ... | @@ -7,8 +7,7 @@ GIT |
7 | 7 | |
8 | 8 | GIT |
9 | 9 | remote: https://gitlab.com/gitlab-org/gitlab_git.git |
10 | - revision: 39bc4f043414f1e49f802ed633fa20e6400bfa49 | |
11 | - ref: 39bc4f043414f1e49f802ed633fa20e6400bfa49 | |
10 | + revision: 9e833986399f967e535e6559ac8c3d2c66ae046c | |
12 | 11 | specs: |
13 | 12 | gitlab_git (5.1.0.pre) |
14 | 13 | activesupport (~> 4.0.0) |
... | ... | @@ -325,7 +324,7 @@ GEM |
325 | 324 | multi_json (~> 1.0) |
326 | 325 | websocket-driver (>= 0.2.0) |
327 | 326 | polyglot (0.3.3) |
328 | - posix-spawn (0.3.6) | |
327 | + posix-spawn (0.3.8) | |
329 | 328 | protected_attributes (1.0.5) |
330 | 329 | activemodel (>= 4.0.1, < 5.0) |
331 | 330 | pry (0.9.12.4) | ... | ... |
app/helpers/gitlab_markdown_helper.rb
... | ... | @@ -166,14 +166,14 @@ module GitlabMarkdownHelper |
166 | 166 | |
167 | 167 | def file_exists?(path) |
168 | 168 | return false if path.nil? || path.empty? |
169 | - return @repository.blob_at(current_ref, path).present? || @repository.tree(:head, path).entries.any? | |
169 | + return @repository.blob_at(current_sha, path).present? || @repository.tree(current_sha, path).entries.any? | |
170 | 170 | end |
171 | 171 | |
172 | 172 | # Check if the path is pointing to a directory(tree) or a file(blob) |
173 | 173 | # eg. doc/api is directory and doc/README.md is file |
174 | 174 | def local_path(path) |
175 | - return "tree" if @repository.tree(:head, path).entries.any? | |
176 | - return "raw" if @repository.blob_at(current_ref, path).image? | |
175 | + return "tree" if @repository.tree(current_sha, path).entries.any? | |
176 | + return "raw" if @repository.blob_at(current_sha, path).image? | |
177 | 177 | return "blob" |
178 | 178 | end |
179 | 179 | |
... | ... | @@ -181,6 +181,14 @@ module GitlabMarkdownHelper |
181 | 181 | @commit.nil? ? "master" : @commit.id |
182 | 182 | end |
183 | 183 | |
184 | + def current_sha | |
185 | + if @commit | |
186 | + @commit.id | |
187 | + else | |
188 | + @repository.head_commit.sha | |
189 | + end | |
190 | + end | |
191 | + | |
184 | 192 | # We will assume that if no ref exists we can point to master |
185 | 193 | def correct_ref(ref) |
186 | 194 | ref ? ref : "master" | ... | ... |
app/services/files/create_service.rb
... | ... | @@ -24,7 +24,8 @@ module Files |
24 | 24 | return error("Your changes could not be committed, because file name contains not allowed characters") |
25 | 25 | end |
26 | 26 | |
27 | - blob = repository.blob_at(ref, file_path) | |
27 | + commit = repository.commit(ref) | |
28 | + blob = repository.blob_at(commit.sha, file_path) | |
28 | 29 | |
29 | 30 | if blob |
30 | 31 | return error("Your changes could not be committed, because file with such name exists") | ... | ... |
app/services/files/delete_service.rb
... | ... | @@ -17,7 +17,8 @@ module Files |
17 | 17 | return error("You can only create files if you are on top of a branch") |
18 | 18 | end |
19 | 19 | |
20 | - blob = repository.blob_at(ref, path) | |
20 | + commit = repository.commit(ref) | |
21 | + blob = repository.blob_at(commit.sha, path) | |
21 | 22 | |
22 | 23 | unless blob |
23 | 24 | return error("You can only edit text files") | ... | ... |
app/services/files/update_service.rb
... | ... | @@ -17,7 +17,8 @@ module Files |
17 | 17 | return error("You can only create files if you are on top of a branch") |
18 | 18 | end |
19 | 19 | |
20 | - blob = repository.blob_at(ref, path) | |
20 | + commit = repository.commit(ref) | |
21 | + blob = repository.blob_at(commit.sha, path) | |
21 | 22 | |
22 | 23 | unless blob |
23 | 24 | return error("You can only edit text files") | ... | ... |