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

git helpers #741

Merged
merged 21 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
574fb12
Add Git interface for file selection and declare git variable for rep…
pelikhan Sep 30, 2024
3b19e95
wiring up globlas
pelikhan Sep 30, 2024
adcdd8c
Add git helper functions for branch and file modifications detection
pelikhan Sep 30, 2024
81f2cb5
Use `--porcelain` format in git status to ignore deleted files
pelikhan Sep 30, 2024
682c2d3
Refactor GitClient to use a unified exec method for executing git com…
pelikhan Sep 30, 2024
6897762
Refactor GitClient for scope handling and add diff method with filters
pelikhan Sep 30, 2024
c074fad
Refactor git diff command to use object-based parameters and exclude …
pelikhan Sep 30, 2024
7b9a8e2
Refactor diff parsing and update GitClient to handle excluded paths c…
pelikhan Oct 1, 2024
521cfed
Refactor git diff commands to use new API methods for consistency and…
pelikhan Oct 1, 2024
0f8b13d
refactor: replace host.exec with git.diff and git.exec for cleaner code
pelikhan Oct 1, 2024
822c9e8
Refactor git diff argument handling for clarity and correctness
pelikhan Oct 1, 2024
8b2d555
Enhance chat output by applying prettifyMarkdown function
pelikhan Oct 1, 2024
d58d623
Add verbose logging for default branch retrieval and console output i…
pelikhan Oct 1, 2024
754cca9
Update defaultBranch method to use 'remote show' and add setDefaultBr…
pelikhan Oct 1, 2024
71b3aaa
Change `findModifiedFiles` argument from "branch" to "base" for bette…
pelikhan Oct 1, 2024
c2d5d07
Make glob input dynamic and add prompts for missing variables
pelikhan Oct 1, 2024
145921b
Add askStageOnEmpty option to GitClient and update scripts to use git…
pelikhan Oct 1, 2024
37aa561
Add documentation and refactor diff handling logic in core and vscode…
pelikhan Oct 1, 2024
e1aa1d6
Add trace filename logging and return it from setupTraceWriting function
pelikhan Oct 1, 2024
9a3211d
Refactor git diff execution to use git library and improve context de…
pelikhan Oct 1, 2024
775a5fb
Update git.findModifiedFiles to use "base" instead of "branch"
pelikhan Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docs/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions docs/src/content/docs/reference/scripts/git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
title: Git
description: git helpers
sidebar:
order: 51
---

The `git` helper provides a thin wrapper around invoking the [git](https://git-scm.com/) executable.

Choose a reason for hiding this comment

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

Consider providing an example of how to invoke the git helper for clarity.

generated by pr-docs-review-commit documentation_content


## defaultBranch

Resolve the default branch, typically `main` or `master` in the repository.

```js
const df = await git.defaultBranch()

Check failure on line 15 in docs/src/content/docs/reference/scripts/git.md

View workflow job for this annotation

GitHub Actions / build

Missing function call for `git.defaultBranch`. The code snippet should include how to call the function.

Choose a reason for hiding this comment

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

The code snippet is missing the function call to execute the git.defaultBranch method. It should be git.defaultBranch() instead of await git.defaultBranch(). The await keyword is used with asynchronous functions, and there is no indication that git.defaultBranch is an asynchronous function in this context. If it is asynchronous, the function should be called within an async function or a thenable context.::

generated by pr-docs-review-commit missing_function_call

Choose a reason for hiding this comment

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

The variable df is not descriptive; consider using a more descriptive variable name like defaultBranch.

generated by pr-docs-review-commit variable_naming

Copy link

Choose a reason for hiding this comment

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

The await keyword is used without an async function context. The code snippet should be inside an async function or the documentation should mention that it needs to be used within one.

generated by pr-docs-review-commit await_usage

Copy link

Choose a reason for hiding this comment

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

Missing 'await' keyword before 'git.defaultBranch()' function call.

generated by pr-docs-review-commit missing_await

```
Copy link

Choose a reason for hiding this comment

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

The code snippet is missing the declaration for the 'git' variable. It should show how to import or require the 'git' helper module.

generated by pr-docs-review-commit missing_variable_declaration

Copy link

Choose a reason for hiding this comment

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

The code snippet is missing the function declaration for git.defaultBranch. It should be preceded by an import statement or a function declaration to provide context.

generated by pr-docs-review-commit missing_function_declaration

Copy link

Choose a reason for hiding this comment

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

The code example for 'git.defaultBranch' is incomplete. It should include the import statement and possibly more context for clarity.

generated by pr-docs-review-commit missing_code_example

49 changes: 49 additions & 0 deletions genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions packages/auto/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions packages/core/src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,22 @@
return lines.filter((l) => l !== undefined).join("\n")
}

export function llmifyDiff(diff: string) {
if (!diff) return diff

export function tryParseDiff(diff: string) {
let parsed: parseDiff.File[]
try {
parsed = parseDiff(diff)
} catch (e) {
return undefined // probably not a diff
}
return parsed
}

export function llmifyDiff(diff: string) {
if (!diff) return diff
Copy link

Choose a reason for hiding this comment

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

The function tryParseDiff is called without arguments. This function expects a string argument.

generated by pr-review-commit missing_argument


const parsed = tryParseDiff(diff)
if (!parsed) return undefined

Check failure on line 263 in packages/core/src/diff.ts

View workflow job for this annotation

GitHub Actions / build

The function `tryParseDiff` does not handle errors properly. It returns `undefined` when an error occurs, but it does not log or throw the error, which could make debugging difficult.
Copy link

Choose a reason for hiding this comment

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

The function tryParseDiff does not handle errors properly. It returns undefined when an error occurs, but it does not log or throw the error, which could make debugging difficult.

generated by pr-review-commit missing_error_handling

pelikhan marked this conversation as resolved.
Show resolved Hide resolved
pelikhan marked this conversation as resolved.
Show resolved Hide resolved
for (const file of parsed) {
for (const chunk of file.chunks) {
let currentLineNumber = chunk.newStart
Expand Down
49 changes: 49 additions & 0 deletions packages/core/src/genaisrc/genaiscript.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading