问题
I would like to send my coworkers a link directly to a line number in a file in our TFS repo. Is this possible? If so, how? We are using TFS 2015.
Currently, the best way I have found is to link to the file like so:
http[s]://{TFS-SERVER}[:{PORT}]/tfs/{PROJECT-COLLECTION}/_versionControl#path={PATH-TO-FILE}
Then, Ctrl+G to manually enter the line number. Before I dig through the JavaScript to find how Ctrl+G works, I am hoping someone can help me out.
I have tried variations on this theme, but without sucecss:
http[s]://{TFS-SERVER}[:{PORT}]/tfs/{PROJECT-COLLECTION}/_versionControl#path={PATH-TO-FILE}#line={LINE}
P.S. My issue is similar to this issue but rather than for Visual Studio, I am looking for a link via the TFS web portal.
回答1:
Just heard from a guy inside of Microsoft that adding &line=5
should work. My local tests show it only works for Visual Studio team Services and doesn't work on TFS 2015 update 2. You'll probably have to wait until update 3 for this feature to hit TFS.
In the mean time, the JavaScript simply looks for a div with the right linenumber attribute:
<div linenumber="5">...</div>
回答2:
Once you select a piece of code in VSO code editor, it is possible to copy a link to that section (see picture below). It looks like TFS has pretty similar url structure, maybe it will work.
Generated link structure
https://{PROJECT_URL}/_versionControl?path={FILE_PATH}&line={SELECTION_START_LINE}&lineEnd={SELECTION_END_LINE}&lineStartColumn={SELECTION_START_COLUMN}&lineEndColumn={SELECTION_END_COLUMN}
来源:https://stackoverflow.com/questions/36359580/tfs-web-portal-possible-to-link-uri-directly-to-line-number-in-file