lostintangent / gistpad

VS Code extension for managing and sharing code snippets, notes and interactive samples using GitHub Gists
https://aka.ms/gistpad
MIT License
944 stars 61 forks source link

Repositories do not show content in today's Stable (1.66) #278

Closed carlocardella closed 2 years ago

carlocardella commented 2 years ago

Describe the bug Seems to be a reoccurrence of #274, unfortunately this time it affects both Stable and Insiders release. GistPad Repositories no longer show the repo content (see screenshot below).

To Reproduce Steps to reproduce the behavior:

Install VSCode 1.66 Just open an existing repo

Expected behavior See and edit files in the repo

Screenshots image

Desktop (please complete the following information): GistPad v0.3.0

Version: 1.66.0 (user setup)
Commit: e18005f0f1b33c29e81d732535d8c0e47cafb0b5
Date: 2022-03-30T05:50:14.623Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.22000

Additional context Add any other context about the problem here.

carlocardella commented 2 years ago

I'm not sure if it is related, just found this in VSCode 1.66 release notes: https://code.visualstudio.com/updates/v1_66#_remote-repositories

Previously, the Azure Repos extension depended directly on the GitHub Repositories extension. Azure Repos and GitHub Repositories now depend on a common extension, Remote Repositories, which supports common workflows across GitHub and Azure Repos. All APIs previously exposed by the GitHub Repositories extension are now exposed by Remote Repositories.

Interesting that the API change touches the Remote Repositories area

carlocardella commented 2 years ago

I am trying to take a look, it seems parent.files here is always undefined but I have not yet figured out why

https://github.com/lostintangent/gistpad/blob/0f619e14e9b0540ce26f175d2b9ff2bd3603f3ed/src/repos/tree/index.ts#L56

  getFileNodes(parent: Repository | RepositoryFile, repo: Repository) {
    return parent.files?.map((file) => new RepositoryFileNode(repo, file));
  }
carlocardella commented 2 years ago

Quick update: I have a propotype of a fix working for public repos, I need to figure out what's changed to get private repos too

lostintangent commented 2 years ago

What was the fix for public repos?

carlocardella commented 2 years ago

Do you want me to submit a PR with this first partial fix?

carlocardella commented 2 years ago

For private repos it looks like the token we get from

https://github.com/lostintangent/gistpad/blob/0f619e14e9b0540ce26f175d2b9ff2bd3603f3ed/src/store/auth.ts#L61

does not have enough permission, which is odd because other extensions authorized to use my github authentication can work with private repos. Anyway, if I use the token from that call with Postman I get the same 404 error for a private repo.

carlocardella commented 2 years ago

It turns out there was a problem with the private repo I was using for testing 😮 I can work with other private repos just fine so I have published the PR, please take a look; for the time being I am sideloading my vsix package for day to day use till the fix will be out.

One more note: to be able to debug the extension I had to modify a bunch of vscode files (tasks, launch.json, webpack etc.), let me know if you want me to add those to the PR:

image

carlocardella commented 2 years ago

It turns out there was a problem with the private repo I was using for testing 😮

The problem is the branch: I have created a brand new private repo for testing today and the default branch on Github is now main, but Gispad has master hardcoded in a bunch of places. I'll see if I can make a fix for that as well

image

carlocardella commented 2 years ago

Uhm... it looks like, after todays Stable verision 1.66 Recovery 2, Gists are not loading anymore 😮

image

lostintangent commented 2 years ago

Weird! I haven't touched the gist logic in forever, so VS Code must have shipped an update that included a breaking change in Node.Js or something.

carlocardella commented 2 years ago

Agreed, even when Repos was broken last time (and with the current issues), Gists has always worked perfectly... I don't know what changed with this update but it feels like something in the runtime is less stable. I'll see if I can spend a bit of time on it

carlocardella commented 2 years ago

It turns out there was a problem with the private repo I was using for testing 😮

The problem is the branch: I have created a brand new private repo for testing today and the default branch on Github is now main, but Gispad has master hardcoded in a bunch of places. I'll see if I can make a fix for that as well

image

I just filed a separate PR (#284) for this

valentino-90 commented 2 years ago

Hi, I have the same problem. I have private repositories with any files listed. I create them with the suffix #main because gistpad uses the master branch by default. Once the fix has been found, wouldn't it be useful to choose the default branch name from the settings panel for the next extension update?

screen

carlocardella commented 2 years ago

@valentino-90, with the PR I filed (#284) the default branch is read automatically from GitHub, no need to choose manually: is it ok for your use case?

valentino-90 commented 2 years ago

@carlocardella, ok... but if i create a repository directly from GistPad (in sidebar panel), gistpad will use "master" by default. I always prefer to use "main" everywhere for compatibility with other tools, but currently i can't choose this option.

carlocardella commented 2 years ago

Good point, thanks, I didn't think about that (I always create my repos on GitHub first); I'll try to add it

carlocardella commented 2 years ago

@valentino-90, maybe this deserves a conversation in a dedicated issue: anyway, I just tried to create a new repo and and it automatically used main. Do you want to be able to choose the branch name instead?

Note, in this short video I am using the change in my PR, you do not get this behavior without it:

NewRepoFromGistpad

valentino-90 commented 2 years ago

@carlocardella great, it works because your fix is active in your case. It's ok, but in my opinion there are developers who prefer the "old" style. Maybe using main by default and allow the editing is a good idea for future releases. But, now the priority is the problem of missing files in repository tree.

lostintangent commented 2 years ago

Your PR looks great, and I really appreciate the contribution/help here! I left a few minor comments, but we can go ahead and try to get this merged and released today 🙌