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

fmt: don't change paths when formatting imports #21148

Merged
merged 3 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 13 additions & 1 deletion .github/workflows/v_apps_and_modules_compile_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
# v -cc gcc run /tmp/gitly/tests/first_run.v
# # /tmp/gitly/gitly -ci_run

- name: Build V Language Server (v-analyzer) vlang/v-analyzer
- name: Build vlang/v-analyzer
run: |
echo "Clone v-analyzer"
.github/workflows/retry.sh git clone --depth=1 --filter=blob:none --recursive --shallow-submodules https://github.com/vlang/v-analyzer /tmp/v-analyzer
Expand All @@ -119,6 +119,18 @@ jobs:
echo "Build v-analyzer release"
v build.vsh release

- name: Format vlang/v-analyzer
run: |
cd /tmp/v-analyzer
set +e
v fmt -c .
exit_code=$?
if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
# Don't fail on on internal errors
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# Don't fail on on internal errors
# Don't fail on internal errors

v fmt -diff .
exit 1
fi

- name: Build vlang/go2v
run: |
echo "Clone Go2V"
Expand Down
9 changes: 1 addition & 8 deletions vlib/v/fmt/fmt.v
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,6 @@ pub fn (mut f Fmt) imports(imports []ast.Import) {
}

pub fn (f Fmt) imp_stmt_str(imp ast.Import) string {
mut imp_res := imp.source_name
if imp.mod.starts_with('src.') || (imp.mod.contains('src.') && imp.mod != imp.source_name) {
imp_after_src := imp.mod.all_after('src.')
if imp.source_name.all_after('src.') == imp_after_src {
imp_res = imp_after_src
}
}
// Format / remove unused selective import symbols
// E.g.: `import foo { Foo }` || `import foo as f { Foo }`
has_alias := imp.alias != imp.source_name.all_after_last('.')
Expand All @@ -392,7 +385,7 @@ pub fn (f Fmt) imp_stmt_str(imp ast.Import) string {
' {\n\t' + syms.join(',\n\t') + ',\n}'
}
}
return '${imp_res}${suffix}'
return '${imp.source_name}${suffix}'
}

//=== Node helpers ===//
Expand Down

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion vlib/v/fmt/testdata/vmodules/src_import/src/a/ab/ab.v

This file was deleted.

Empty file.