Skip to content
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

Create repository for single file #2426

merged 3 commits into from Apr 4, 2020


Copy link

@smashwilson smashwilson commented Apr 3, 2020

Please be sure to read the contributor's guide to the GitHub package before submitting any pull requests.


  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • Suggestion: You can use checklists to keep track of progress for the sections on metrics, tests, documentation, and user research.

Description of the Change

Modify the way that active pane item paths are used to influence the active context paths. Specifically:

  • If the item path is not within a beneath one of the open project roots, use that project root instead.
  • If the item path is not a directory, use its containing directory.



Alternate Designs



The "repository path" derived from paths within non-git-working-directory project roots will behave more predictably. (This path is used by the "create repository" blank state of the git and GitHub tabs, for example.)

Previously, if you:

  • Opened a (non-git) project root /some/root
  • Opened a file within a subdirectory of it (/some/root/subdir/a.txt)
  • Opened the Git tab.

The Git tab would previously prompt you to initialize a repo at /some/root/subdir/a.txt, which doesn't make any sense and would fail. After this change, it would prompt you to initialize at /some/root instead.

Similarly, if you opened a path /a/long/path/b.txt that was outside of any git working directory, you'd be prompted to initialize at /a/long/path/b.txt, but now you'll be prompted to initialize at /a/long/path`.

Possible Drawbacks

We don't officially support submodules... but this will likely mess them up further, by preventing you from ever having a submodule as an active path if its parent repo was a project root. I'll investigate how badly it fails before I merge this.

Update: it did indeed break the ability to perform operations within submodules. I've rewritten it to only normalize workdir candidate paths that don't map to git workdirs, which lets us have the best of both worlds.

Applicable Issues

Fixes #2407.

Release Notes

  • The GitHub package will no longer offer to initialize git repositories at non-directory paths.

Copy link

codecov bot commented Apr 3, 2020

Codecov Report

Merging #2426 into master will decrease coverage by 0.17%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2426      +/-   ##
- Coverage   93.25%   93.07%   -0.18%     
  Files         235      235              
  Lines       13163    13178      +15     
  Branches     1889     1892       +3     
- Hits        12275    12266       -9     
- Misses        888      912      +24     
Impacted Files Coverage Δ
lib/github-package.js 75.16% <100.00%> (+0.92%) ⬆️
lib/shared/keytar-strategy.js 38.75% <0.00%> (-8.53%) ⬇️
lib/models/file-system-change-observer.js 88.00% <0.00%> (-8.00%) ⬇️
lib/git-temp-dir.js 96.77% <0.00%> (-3.23%) ⬇️
lib/git-prompt-server.js 97.29% <0.00%> (-2.71%) ⬇️
lib/helpers.js 86.41% <0.00%> (-1.24%) ⬇️
lib/git-shell-out-strategy.js 99.23% <0.00%> (-0.58%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41aaa3f...3a5b5ad. Read the comment docs.

@smashwilson smashwilson marked this pull request as ready for review Apr 4, 2020
@smashwilson smashwilson merged commit 70b0925 into master Apr 4, 2020
2 checks passed
@smashwilson smashwilson deleted the create-repository-for-single-file branch Apr 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Wrong path when create repository for single files
1 participant