Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
bd2ca33d
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 搜索 >>
提交
bd2ca33d
编写于
11月 12, 2013
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'relative' of /home/git/repositories/gitlab/gitlabhq
上级
99334d4b
4e9284a0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
21 addition
and
4 deletion
+21
-4
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+10
-3
lib/redcarpet/render/gitlab_html.rb
lib/redcarpet/render/gitlab_html.rb
+1
-1
spec/factories.rb
spec/factories.rb
+1
-0
spec/support/test_env.rb
spec/support/test_env.rb
+9
-0
未找到文件。
app/helpers/gitlab_markdown_helper.rb
浏览文件 @
bd2ca33d
...
...
@@ -64,7 +64,9 @@ module GitlabMarkdownHelper
# ref - name of the branch or reference, eg. stable
# requested_path - path of request, eg. doc/api/README.md, used in special case when path is pointing to the .md file were the original request is coming from
# wiki - whether the markdown is from wiki or not
def
create_relative_links
(
text
,
project_path_with_namespace
,
ref
,
requested_path
,
wiki
=
false
)
def
create_relative_links
(
text
,
project
,
ref
,
requested_path
,
wiki
=
false
)
@path_to_satellite
=
project
.
satellite
.
path
project_path_with_namespace
=
project
.
path_with_namespace
paths
=
extract_paths
(
text
)
paths
.
each
do
|
file_path
|
new_path
=
rebuild_path
(
project_path_with_namespace
,
file_path
,
requested_path
,
ref
)
...
...
@@ -145,13 +147,18 @@ module GitlabMarkdownHelper
def
file_exists?
(
path
)
return
false
if
path
.
nil?
||
path
.
empty?
File
.
exists?
(
Rails
.
root
.
join
(
path
))
File
.
exists?
(
path_on_fs
(
path
))
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
)
File
.
directory?
(
Rails
.
root
.
join
(
path
))
?
"tree"
:
"blob"
File
.
directory?
(
path_on_fs
(
path
))
?
"tree"
:
"blob"
end
# Path to the file in the satellites repository on the filesystem
def
path_on_fs
(
path
)
[
@path_to_satellite
,
path
].
join
(
"/"
)
end
# We will assume that if no ref exists we can point to master
...
...
lib/redcarpet/render/gitlab_html.rb
浏览文件 @
bd2ca33d
...
...
@@ -36,7 +36,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def
preprocess
(
full_document
)
if
@project
h
.
create_relative_links
(
full_document
,
@project
.
path_with_namespace
,
@ref
,
@request_path
,
is_wiki?
)
h
.
create_relative_links
(
full_document
,
@project
,
@ref
,
@request_path
,
is_wiki?
)
else
full_document
end
...
...
spec/factories.rb
浏览文件 @
bd2ca33d
...
...
@@ -66,6 +66,7 @@ FactoryGirl.define do
after
:create
do
|
project
|
TestEnv
.
clear_repo_dir
(
project
.
namespace
,
project
.
path
)
TestEnv
.
reset_satellite_dir
TestEnv
.
create_repo
(
project
.
namespace
,
project
.
path
)
end
end
...
...
spec/support/test_env.rb
浏览文件 @
bd2ca33d
...
...
@@ -97,6 +97,15 @@ module TestEnv
FileUtils
.
rm_rf
File
.
join
(
testing_path
(),
"
#{
name
}
.wiki.git"
)
end
def
reset_satellite_dir
setup_stubs
FileUtils
.
cd
(
seed_satellite_path
)
do
`git reset --hard --quiet`
`git clean -fx`
`git checkout --quiet origin/master`
end
end
# Create a repo and it's satellite
def
create_repo
(
namespace
,
name
)
setup_stubs
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录