如何在GitHub问题中使用源代码链接?

时间:2014-12-23 07:35:15

标签: github

有源代码' mysource.py'在GitHub的存储库中。

mysource.py

1: def func1():
2:    for i in range(10);
3:        print 'hello world'
4: 
5: def func2():
6:     for i in range(10);
7:        print 'hello world'

我希望在GitHub Issue中引用源代码的第5到7行。像这样

5: def func2():
6:     for i in range(10);
7:        print 'hello world'

如果没有“只是复制并粘贴”,我怎么能这样做呢?我可以使用源代码的链接吗?

3 个答案:

答案 0 :(得分:1)

不,这是不可能的。但是,您可以在拉动请求的“文件已更改”选项卡上创建行注释,这些注释可以通过标准#referencing引用问题。

答案 1 :(得分:1)

您可以添加以下哈希片段。

https://github.com/username/repo/mysource.py#L5-L7

只是在没有知道可能的情况下尝试过它。

答案 2 :(得分:0)

您现在可以通过选择行范围并使用“创建问题”菜单选项来执行此操作:

示例

screen shot of the menu available after selecting lines in a source file on Github

...导致:

screen shot of the resulting Github issue created, with a code listing inline in the issue via a link

步骤

  1. 转到源文件
  2. 选择行范围(例如,单击感兴趣的第一行,然后按住Shift并单击最后一行)
  3. 从左侧的...菜单中,选择“严重问题”
  4. 将出现一个问题页面,其中包含指向这些行的链接,该链接呈现为源代码视图。