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,7 +29,7 @@ gem 'omniauth-github' | ||
29 | 29 | ||
30 | # Extracting information from a git repository | 30 | # Extracting information from a git repository |
31 | # Provide access to Gitlab::Git library | 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 | # Ruby/Rack Git Smart-HTTP Server Handler | 34 | # Ruby/Rack Git Smart-HTTP Server Handler |
35 | gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' | 35 | gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack' |
Gemfile.lock
@@ -7,8 +7,7 @@ GIT | @@ -7,8 +7,7 @@ GIT | ||
7 | 7 | ||
8 | GIT | 8 | GIT |
9 | remote: https://gitlab.com/gitlab-org/gitlab_git.git | 9 | remote: https://gitlab.com/gitlab-org/gitlab_git.git |
10 | - revision: 39bc4f043414f1e49f802ed633fa20e6400bfa49 | ||
11 | - ref: 39bc4f043414f1e49f802ed633fa20e6400bfa49 | 10 | + revision: 9e833986399f967e535e6559ac8c3d2c66ae046c |
12 | specs: | 11 | specs: |
13 | gitlab_git (5.1.0.pre) | 12 | gitlab_git (5.1.0.pre) |
14 | activesupport (~> 4.0.0) | 13 | activesupport (~> 4.0.0) |
@@ -325,7 +324,7 @@ GEM | @@ -325,7 +324,7 @@ GEM | ||
325 | multi_json (~> 1.0) | 324 | multi_json (~> 1.0) |
326 | websocket-driver (>= 0.2.0) | 325 | websocket-driver (>= 0.2.0) |
327 | polyglot (0.3.3) | 326 | polyglot (0.3.3) |
328 | - posix-spawn (0.3.6) | 327 | + posix-spawn (0.3.8) |
329 | protected_attributes (1.0.5) | 328 | protected_attributes (1.0.5) |
330 | activemodel (>= 4.0.1, < 5.0) | 329 | activemodel (>= 4.0.1, < 5.0) |
331 | pry (0.9.12.4) | 330 | pry (0.9.12.4) |
app/helpers/gitlab_markdown_helper.rb
@@ -166,14 +166,14 @@ module GitlabMarkdownHelper | @@ -166,14 +166,14 @@ module GitlabMarkdownHelper | ||
166 | 166 | ||
167 | def file_exists?(path) | 167 | def file_exists?(path) |
168 | return false if path.nil? || path.empty? | 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 | end | 170 | end |
171 | 171 | ||
172 | # Check if the path is pointing to a directory(tree) or a file(blob) | 172 | # Check if the path is pointing to a directory(tree) or a file(blob) |
173 | # eg. doc/api is directory and doc/README.md is file | 173 | # eg. doc/api is directory and doc/README.md is file |
174 | def local_path(path) | 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 | return "blob" | 177 | return "blob" |
178 | end | 178 | end |
179 | 179 | ||
@@ -181,6 +181,14 @@ module GitlabMarkdownHelper | @@ -181,6 +181,14 @@ module GitlabMarkdownHelper | ||
181 | @commit.nil? ? "master" : @commit.id | 181 | @commit.nil? ? "master" : @commit.id |
182 | end | 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 | # We will assume that if no ref exists we can point to master | 192 | # We will assume that if no ref exists we can point to master |
185 | def correct_ref(ref) | 193 | def correct_ref(ref) |
186 | ref ? ref : "master" | 194 | ref ? ref : "master" |
app/services/files/create_service.rb
@@ -24,7 +24,8 @@ module Files | @@ -24,7 +24,8 @@ module Files | ||
24 | return error("Your changes could not be committed, because file name contains not allowed characters") | 24 | return error("Your changes could not be committed, because file name contains not allowed characters") |
25 | end | 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 | if blob | 30 | if blob |
30 | return error("Your changes could not be committed, because file with such name exists") | 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,7 +17,8 @@ module Files | ||
17 | return error("You can only create files if you are on top of a branch") | 17 | return error("You can only create files if you are on top of a branch") |
18 | end | 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 | unless blob | 23 | unless blob |
23 | return error("You can only edit text files") | 24 | return error("You can only edit text files") |
app/services/files/update_service.rb
@@ -17,7 +17,8 @@ module Files | @@ -17,7 +17,8 @@ module Files | ||
17 | return error("You can only create files if you are on top of a branch") | 17 | return error("You can only create files if you are on top of a branch") |
18 | end | 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 | unless blob | 23 | unless blob |
23 | return error("You can only edit text files") | 24 | return error("You can only edit text files") |