Import testproj databases into workspace storage#3433
Conversation
If a folder that ends with `.testproj` is encountered, assume it is a database created by a codeql test. When the user wants to import this database, copy it into workspace storage. The database can be re-imported, which first removes the old version before importing it again.
Before running a query now, do the following: 1. Check if the selected database is imported from a testproj 2. If so, check the last modified time of the `codeql-datase.yml` file of the imported database with that of its origin. 3. If the origin database has a file that is newer, assume that the database has been recreated since the last time it was imported. 4. If newer, then ask the user if they want to re-import before running the query. Also, this change appends the `(test)` label to all test databases in the database list.
extensions/ql-vscode/package.json
Outdated
| "ts-unused-exports": "^10.0.0", | ||
| "typescript": "^5.0.2" | ||
| "typescript": "^5.0.2", | ||
| "unzipper": "^0.10.14" |
There was a problem hiding this comment.
I haven't looked at the full PR yet, but is there a reason we need to be using unzipper here? We do already have yauzl as a dependency and some helpers functions in unzip.ts and unzip-concurrently.ts.
There was a problem hiding this comment.
Thanks. I wasn't aware of those dependencies. I can switch.
And fix linting error.
|
I'm not sure what's happening with the |
|
Two possibilities come to mind:
|
|
The next thing to try would be to add a few second wait on windows. |
|
OK...that seems to have worked, but it's not a great solution. |
c8de5c8 to
0ed9242
Compare
koesie10
left a comment
There was a problem hiding this comment.
Everything seems to be working well for me, I just have some minor comments.
extensions/ql-vscode/src/databases/local-databases/database-manager.ts
Outdated
Show resolved
Hide resolved
extensions/ql-vscode/test/vscode-tests/cli-integration/utils.ts
Outdated
Show resolved
Hide resolved
koesie10
left a comment
There was a problem hiding this comment.
LGTM. However, there are some confusing logs when you re-import a database before running a query. I see the following log lines:
Deleting database from filesystem.
Deleted '/Users/koesie10/Library/Application Support/Code/User/workspaceStorage/c3466bf33a6faffab7f413267a6ffe3f/GitHub.vscode-codeql/modeleditor-1'
However, there's nothing to indicate that the database has been imported again, so it'd be good to add that as well.
| origin, | ||
| progress, | ||
| cli, | ||
| ); |
There was a problem hiding this comment.
I can't leave a comment on the exact line, but there's a message "Database unzipped and imported successfully.", which is somewhat confusing if you're importing a testproj database since nothing is being unzipped. Could this message be changed when you're using a testproj database?
211671b to
ed9c95e
Compare
ed9c95e to
2d85018
Compare
|
Thanks for such a detailed review, Koen! |
Commit-by-commit review is recommended.
If a folder that ends with
.testprojis encountered, assume it is adatabase created by a codeql test. When the user wants to import this
database, copy it into workspace storage. The database can be
re-imported, which first removes the old version before importing it
again.
Ask user if they want to re-import outdated testproj dbs
Before running a query now, do the following:
codeql-datase.ymlfileof the imported database with that of its origin.
database has been recreated since the last time it was imported.
the query.
Also, this change appends the
(test)label to all test databases inthe database list.
To verify this change, do the following:
test.testprojdirectory and select "(Re-)Import test database"1as the result.select 2yes2.Checklist
ready-for-doc-reviewlabel there.