Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

[spike] Open from GitHub URL #1763

Merged
merged 44 commits into from
Jul 13, 2018
Merged

[spike] Open from GitHub URL #1763

merged 44 commits into from
Jul 13, 2018

Conversation

jcansdale
Copy link
Collaborator

@jcansdale jcansdale commented Jun 25, 2018

UPDATE

I need update the description for this PR!

Please use Code context > GitHub > Open from clipboard rather than File > Open > Open from GitHub.

Original spike

Clone or open any repository, file or PR from a GitHub URL.

How to use:

  1. Copy a GitHub URL into paste buffer
  2. Select File > Open > Open from GitHub

This command will:

  1. Clone the repository if it doesn't already exist
  2. Open the repository folder if not already open
  3. Open target file if GitHub URL contains file information
  4. Navigate to line number if GitHub URL contains line information
  5. Open target PR if GitHub URL contains PR information

Currently this will happen with no further user interaction. The repository will be opened from the following default path:
<DefaultClonePath>\GitHubCache\<RepositoryOwner>\<RepositoryName>

The location will be unique and won't stomp over existing repositories. Need to think about UI for selecting a non-default repository location.

Related: #1757

Use `GitHub.OpenFromUrl <url>` from the VS Command Window to clone a
target URL. This spike uses existing `ShowReCloneDialog` method.
Expect Owner="github", RepositoryName="VisualStudio" from:
https://github.com/github/VisualStudio/blob/master/README.md

Not Owner="master", RepositoryName="README.md"
Only files on master branch are currently supported.
Trim line number when using FindPath.
Prototype this using the happy path where we use the default repository
location.
If we're already in an appropriate context, simply open the target file.
The following URL will now have an owner of "owner":
https://github.com/owner
Previously it would make a repository name of "owner".
Add code to parse window titles and find the GitHub context from the
topmost Chrome browser.
If there is no URL in the paste buffer, use the GitHub context from the
topmost browser.
jcansdale added 14 commits June 27, 2018 16:38
When browser is in the context of a file, open a file with the same
name after repository is opened.
OpenFromUrlCommand now works with GitHubContext objects rather than
directly with URLs.
Visual Studio line numbers are zero based.
Assume that branch names don't contain a '/' (sic).
Navigate to line when line number information is available.
Search for Chrome then Firefox windows.
Need to find a way to search in order of height.
Previously highlighting only worked when a range was selected.
Use VsShellUtilities.OpenDocument instead of
DTE.ItemOperations.OpenFile.
Factor TryOpenFile into GitHubContextService.
Don't continue to column 0 on the line below.
jcansdale added 17 commits July 3, 2018 17:34
GitHub URLs combine branches/SHAs and tree paths.

For example:
https://github.com/github/visualstudio/tree/master/src

Git would represent "master/src" as the tree-ish "master:src". Because
looking at the URL we don't know where the branch stops and the tree
starts, "master/src" is being stored as the TreeishPath property.
This enables round tripping between `Copy link to clipboard` and `Open
from GitHub`.
This is a mirror of `GitHub.CopyLink`.
Check that object exists before navigating.
Currently doesn't support opening/cloning repo so show message instead.
Interface shouldn't depend on LibGit2Sharp and return stale GitObject.
This will let us give user more meaningful warnings.
Warn if there have been chances to the target file between when the
permalink was created and the working copy.
We don't want to navigate to a stale source file, so show the original
blob using the AnnotateFile view.
This method only knows how to resolve blobs (not commits or trees).
Everything now uses ResolveBlob.
@jcansdale jcansdale mentioned this pull request Jul 9, 2018
2 tasks
@meaghanlewis meaghanlewis merged commit 6a3d8e4 into master Jul 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants