Merge branch 'gitlab_git_rugged' into 'master'
gitlab_git with rugged Updated gitlab_git version with Blob via rugged
This commit is contained in:
commit
d701d58695
2
Gemfile
2
Gemfile
|
@ -29,7 +29,7 @@ gem 'omniauth-github'
|
|||
|
||||
# Extracting information from a git repository
|
||||
# Provide access to Gitlab::Git library
|
||||
gem "gitlab_git", git: 'https://gitlab.com/gitlab-org/gitlab_git.git', ref: '39bc4f043414f1e49f802ed633fa20e6400bfa49'
|
||||
gem "gitlab_git", git: 'https://gitlab.com/gitlab-org/gitlab_git.git'
|
||||
|
||||
# Ruby/Rack Git Smart-HTTP Server Handler
|
||||
gem 'gitlab-grack', '~> 2.0.0.pre', require: 'grack'
|
||||
|
|
|
@ -7,8 +7,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: https://gitlab.com/gitlab-org/gitlab_git.git
|
||||
revision: 39bc4f043414f1e49f802ed633fa20e6400bfa49
|
||||
ref: 39bc4f043414f1e49f802ed633fa20e6400bfa49
|
||||
revision: 9e833986399f967e535e6559ac8c3d2c66ae046c
|
||||
specs:
|
||||
gitlab_git (5.1.0.pre)
|
||||
activesupport (~> 4.0.0)
|
||||
|
@ -325,7 +324,7 @@ GEM
|
|||
multi_json (~> 1.0)
|
||||
websocket-driver (>= 0.2.0)
|
||||
polyglot (0.3.3)
|
||||
posix-spawn (0.3.6)
|
||||
posix-spawn (0.3.8)
|
||||
protected_attributes (1.0.5)
|
||||
activemodel (>= 4.0.1, < 5.0)
|
||||
pry (0.9.12.4)
|
||||
|
|
|
@ -166,14 +166,14 @@ module GitlabMarkdownHelper
|
|||
|
||||
def file_exists?(path)
|
||||
return false if path.nil? || path.empty?
|
||||
return @repository.blob_at(current_ref, path).present? || @repository.tree(:head, path).entries.any?
|
||||
return @repository.blob_at(current_sha, path).present? || @repository.tree(current_sha, path).entries.any?
|
||||
end
|
||||
|
||||
# Check if the path is pointing to a directory(tree) or a file(blob)
|
||||
# eg. doc/api is directory and doc/README.md is file
|
||||
def local_path(path)
|
||||
return "tree" if @repository.tree(:head, path).entries.any?
|
||||
return "raw" if @repository.blob_at(current_ref, path).image?
|
||||
return "tree" if @repository.tree(current_sha, path).entries.any?
|
||||
return "raw" if @repository.blob_at(current_sha, path).image?
|
||||
return "blob"
|
||||
end
|
||||
|
||||
|
@ -181,6 +181,14 @@ module GitlabMarkdownHelper
|
|||
@commit.nil? ? "master" : @commit.id
|
||||
end
|
||||
|
||||
def current_sha
|
||||
if @commit
|
||||
@commit.id
|
||||
else
|
||||
@repository.head_commit.sha
|
||||
end
|
||||
end
|
||||
|
||||
# We will assume that if no ref exists we can point to master
|
||||
def correct_ref(ref)
|
||||
ref ? ref : "master"
|
||||
|
|
|
@ -24,7 +24,8 @@ module Files
|
|||
return error("Your changes could not be committed, because file name contains not allowed characters")
|
||||
end
|
||||
|
||||
blob = repository.blob_at(ref, file_path)
|
||||
commit = repository.commit(ref)
|
||||
blob = repository.blob_at(commit.sha, file_path)
|
||||
|
||||
if blob
|
||||
return error("Your changes could not be committed, because file with such name exists")
|
||||
|
|
|
@ -17,7 +17,8 @@ module Files
|
|||
return error("You can only create files if you are on top of a branch")
|
||||
end
|
||||
|
||||
blob = repository.blob_at(ref, path)
|
||||
commit = repository.commit(ref)
|
||||
blob = repository.blob_at(commit.sha, path)
|
||||
|
||||
unless blob
|
||||
return error("You can only edit text files")
|
||||
|
|
|
@ -17,7 +17,8 @@ module Files
|
|||
return error("You can only create files if you are on top of a branch")
|
||||
end
|
||||
|
||||
blob = repository.blob_at(ref, path)
|
||||
commit = repository.commit(ref)
|
||||
blob = repository.blob_at(commit.sha, path)
|
||||
|
||||
unless blob
|
||||
return error("You can only edit text files")
|
||||
|
|
Loading…
Reference in New Issue