New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blob and tree gfm links to anchors work. #6375

Merged
merged 1 commit into from Feb 25, 2014

Conversation

2 participants
@cirosantilli
Contributor

cirosantilli commented Feb 21, 2014

Fixes #6046 bug

Intended Behavior

When on a tree directory such as path/name/tree/branch/dir, in the rendered README.md:

[0]() | path/name/tree/branch/dir | current behavior.
[1](#id) | path/name/tree/branch/dir#id | new. Before opened wiki.
[2](file.md#id) | path/name/blob/branch/dir/file.md#id | new

When on a markdown blob such as path/name/blob/branch/dir/file.md:

[0]() | path/name/blob/branch/dir/file.md | current
[1](#id) | path/name/blob/branch/dir/file.md#id | new
[2](file2.md#id) | path/name/blob/branch/dir/file2.md#id | new

This differs slightly from GitHub behavior, in which [empty]() always points to a non existent URL.

I feel that this behavior makes more sense, because if "#a" points to the current file, then "" should too.

The following is the diff for the tests under spec/seed_project.tar.gz. Only the markdown branch was modified with a new commit added. Rationale is explianed on the comments under features/steps/project/project_markdown_render.rb and spec/factories.rb#project.

diff --git a/README.md b/README.md
index 7577fc5..96c09cf 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,11 @@
+This branch is meant to be used with for markdown tests.
+
+Do not rely on its commit message or SHA being constant.
+
# Welcome to GitLab [![build status](https://secure.travis-ci.org/gitlabhq/gitlabhq.png)](https://secure.travis-ci.org/gitlabhq/gitlabhq)

GitLab is a free project and repository management application

-
## Application details

* rails 3.1
@@ -53,3 +56,15 @@ Email

Want to help - send a pull request.
We'll accept good pull requests.
+
+# Links with IDs
+
+[empty]()
+
+[#id](#id)
+
+[/#id](/#id)
+
+[README.md#id](README.md#id)
+
+[d/README.md#id](db/README.md#id)
diff --git a/d/README.md b/d/README.md
new file mode 100644
index 0000000..78addd3
--- /dev/null
+++ b/d/README.md
@@ -0,0 +1,9 @@
+[empty]()
+
+[#id](#id)
+
+[/#id](/#id)
+
+[README.md#id](README.md#id)
+
+[d/README.md#id](db/README.md#id)
@dzaporozhets

This comment has been minimized.

Member

dzaporozhets commented Feb 25, 2014

@cirosantilli look good. Thank you

dzaporozhets added a commit that referenced this pull request Feb 25, 2014

Merge pull request #6375 from cirosantilli/link-with-id
Blob and tree gfm links to anchors work.

@dzaporozhets dzaporozhets merged commit 9f20580 into gitlabhq:master Feb 25, 2014

1 check passed

default The Travis CI build passed
Details

@cirosantilli cirosantilli deleted the booktree:link-with-id branch Apr 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment