Skip to content

Automatically name extension packs#2520

Merged
koesie10 merged 13 commits intomainfrom
koesie10/auto-name-extension-pack
Jun 22, 2023
Merged

Automatically name extension packs#2520
koesie10 merged 13 commits intomainfrom
koesie10/auto-name-extension-pack

Conversation

@koesie10
Copy link
Copy Markdown
Member

This will change how extension packs are named in the data extensions editor. Before, the user had to pick a workspace folder and a name for the extension pack. Now, the workspace folder will be picked automatically if we can detect it (i.e. it follows the naming structure we expect), or the user will still need to select it. The extension pack name is always auto-generated based on the database name and the database language.

This adds a new codeQL.dataExtensions.disableAutoNameExtensionPack setting to disable this behavior while we are still working on changing how the data extensions editor works.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

This will change how extension packs are named in the data extensions
editor. Before, the user had to pick a workspace folder and a name for
the extension pack. Now, the workspace folder will be picked
automatically if we can detect it (i.e. it follows the naming structure
we expect), or the user will still need to select it. The extension pack
name is always auto-generated based on the database name and the
database language.

This adds a new `codeQL.dataExtensions.disableAutoNameExtensionPack`
setting to disable this behavior while we are still working on changing
how the data extensions editor works.
@koesie10 koesie10 requested a review from starcke June 16, 2023 11:51
@koesie10 koesie10 marked this pull request as ready for review June 16, 2023 11:51
@koesie10 koesie10 requested review from a team as code owners June 16, 2023 11:51
@koesie10 koesie10 force-pushed the koesie10/auto-name-extension-pack branch from 928fed1 to 5d83ac8 Compare June 16, 2023 14:01
Copy link
Copy Markdown
Contributor

@starcke starcke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, just some smaller comments.

It felt a bit to odd to me that we just created the pack file but asked about the model file name. I would personally have expected the opposite. Later we do want the yml file to be based on the library name, so I am fine with it like this if that is easier.

Copy link
Copy Markdown
Member Author

@koesie10 koesie10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It felt a bit to odd to me that we just created the pack file but asked about the model file name. I would personally have expected the opposite. Later we do want the yml file to be based on the library name, so I am fine with it like this if that is easier.

They are essentially independent, so I've done only the extension pack name in this PR to keep the sizes of the PRs manageable. The model file name is in #2521. That means that for now the flow is a bit strange, but it helps to keep the changes minimal.

@koesie10 koesie10 requested a review from starcke June 19, 2023 12:34
@koesie10 koesie10 force-pushed the koesie10/auto-name-extension-pack branch from a0820d7 to cfc66a4 Compare June 20, 2023 09:16
return Uri.joinPath(workspaceFile, "..");
}

const workspaceFolders = getOnDiskWorkspaceFoldersObjects();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does getOnDiskWorkspaceFoldersObjects return only file: URIs? If not, you will need to filter out the all the other ones.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's exactly what getOnDiskWorkspaceFoldersObjects does, so this should only return workspace folders which actually exist on-disk.

// The path closest to the workspace folders is the last element of the common root
const commonRootUri = commonRoot[commonRoot.length - 1];

// If we are at the root of the filesystem, we can't go up any further and there's something
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be reasonably common in codeql projets. There's a quick-query command that creates a temp folder and adds it to the workspace. Any workspace that has a quick query folder will only have a common root at /.

Perhaps you will want to filter folders in the temp directory?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, maybe look for a .git folder?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added both filtering out temp directories and looking for the .git folder. If it can't find a common ancestor, it will now try to find the .git folder closest to one of the workspace folders and pick that.

Copy link
Copy Markdown
Contributor

@aeisenberg aeisenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Not necessary for this PR, but the heuristic for choosing a location for extension packs is quite complicated. It would be good to see it documented somewhere. (Either in code as comments, or in a separate document.)

@koesie10 koesie10 enabled auto-merge June 22, 2023 08:19
@koesie10 koesie10 merged commit 100b557 into main Jun 22, 2023
@koesie10 koesie10 deleted the koesie10/auto-name-extension-pack branch June 22, 2023 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants