Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
99518546
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
99518546
编写于
7月 04, 2016
作者:
T
tiagonbotelho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
creates the update_file method in repository.rb and applies changes accordingly
上级
385afc28
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
3 deletion
+35
-3
app/controllers/concerns/creates_commit.rb
app/controllers/concerns/creates_commit.rb
+2
-1
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+1
-1
app/models/repository.rb
app/models/repository.rb
+30
-0
app/services/files/base_service.rb
app/services/files/base_service.rb
+1
-0
app/services/files/update_service.rb
app/services/files/update_service.rb
+1
-1
未找到文件。
app/controllers/concerns/creates_commit.rb
浏览文件 @
99518546
...
...
@@ -8,7 +8,8 @@ module CreatesCommit
source_project:
@project
,
source_branch:
@ref
,
target_branch:
@target_branch
,
file_path:
@path
file_path:
@path
,
previous_path:
@previous_path
)
result
=
service
.
new
(
@tree_edit_project
,
current_user
,
commit_params
).
execute
...
...
app/controllers/projects/blob_controller.rb
浏览文件 @
99518546
...
...
@@ -44,7 +44,7 @@ class Projects::BlobController < Projects::ApplicationController
"#file-path-
#{
hexdigest
(
@path
)
}
"
else
unless
params
[
:file_name
]
==
@path
previous_path
=
@path
@
previous_path
=
@path
@path
=
params
[
:file_name
]
end
namespace_project_blob_path
(
@project
.
namespace
,
@project
,
File
.
join
(
@target_branch
,
@path
))
...
...
app/models/repository.rb
浏览文件 @
99518546
...
...
@@ -731,6 +731,36 @@ class Repository
end
end
def
update_file
(
user
,
path
,
previous_path
,
content
,
message
,
branch
,
update
)
commit_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
options
=
{}
options
[
:committer
]
=
committer
options
[
:author
]
=
committer
options
[
:commit
]
=
{
message:
message
,
branch:
ref
,
}
if
previous_path
options
[
:file
]
=
{
path:
previous_path
}
Gitlab
::
Git
::
Blob
.
remove
(
raw_repository
,
options
)
end
options
[
:file
]
=
{
content:
content
,
path:
path
,
update:
update
}
Gitlab
::
Git
::
Blob
.
commit
(
raw_repository
,
options
)
end
end
def
remove_file
(
user
,
path
,
message
,
branch
)
commit_with_hooks
(
user
,
branch
)
do
|
ref
|
committer
=
user_to_committer
(
user
)
...
...
app/services/files/base_service.rb
浏览文件 @
99518546
...
...
@@ -9,6 +9,7 @@ module Files
@commit_message
=
params
[
:commit_message
]
@file_path
=
params
[
:file_path
]
@previous_path
=
params
[
:previous_path
]
@file_content
=
if
params
[
:file_content_encoding
]
==
'base64'
Base64
.
decode64
(
params
[
:file_content
])
else
...
...
app/services/files/update_service.rb
浏览文件 @
99518546
...
...
@@ -4,7 +4,7 @@ module Files
class
UpdateService
<
Files
::
BaseService
def
commit
# Need to update file_path with the new filename
repository
.
commit_file
(
current_user
,
@file
_path
,
@file_content
,
@commit_message
,
@target_branch
,
true
)
repository
.
update_file
(
current_user
,
@file_path
,
@previous
_path
,
@file_content
,
@commit_message
,
@target_branch
,
true
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录