Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

About line endings

Aperta
#56 16 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
git, visualbasic
Ambito
tooling

Direzione di ricerca

Inizia leggendo il file .gitattributes attuale del repository e la modifica ai caratteri di fine riga di PR 43. Confronta gli approcci proposti -text, filter/.gitconfig e GitHub Action, quindi verifica il comportamento selezionato per i file VBA ottenuti tramite clonazione, download di archivi e download di file raw da GitHub. Il lavoro è completato quando l'approccio scelto è documentato e i file VBA vengono importati correttamente in VBE.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I notice that in this PR https://github.com/Beakerboy/VBA-SQL-Library/pull/43, you added a .gitattributes file that makes it so that line endings are converted to LF in the Git index.

I've personally read in a few places that it was a good practice as well, but I've recently come to the conclusion that normalizing line endings to LF for VBA files doesn't actually bring any value because GitHub is already smart enough to deal with CRLF line endings.

The problem with eol=clrf is that the conversion to CRLF only occurs when someone clones the repo or downloads it as a .zip file. GitHub won't make the line ending conversion when someone downloads a single file using the "Download raw file" option in the GitHub interface.

Then, people that don't know about this problem will inevitably try to down a single file from the project and get an error when trying to import it in the VBE. For example: https://github.com/VBA-tools/VBA-Dictionary/issues/38

For that reason and because there is no known advantages to convert to LF, I'd suggest to change the .gitattributes file to avoid applying line conversion.

Potential approaches

  1. Mark the vba files with -text to avoid line endings conversion.

This is the simplest way to avoid most problems. The only downside of this approach is that it doesn't stop anyone from uploading a file with LF.

  1. Approach 1 + Use a filter to force the conversion to CRLF.

This approach is particularily useful if you make edits via VScode and don't what to introduce LF by mistake. However, it requires contributors to run a command to inlcude the .gitconfig to their local config.

For example:

.gitattributes:

# By default, auto detect text files and perform LF normalization
* text=auto eol=lf

# Important: To make sure the crlf filter is active, run the following command at the root of the git repo: git config include.path ../.gitconfig
# (The reason why we need the ".." is to move one folder up because the config file is located in the .git subfolder.)

# VBA extensions - Enforce CRLF using a filter
*.[bB][aA][sS]      filter=crlf -text working-tree-encoding=CP1252 
*.[cC][lL][sS]      filter=crlf -text working-tree-encoding=CP1252 
*.[fF][rR][mM]      filter=crlf -text working-tree-encoding=CP1252
*.[vV][bB][aA]      filter=crlf -text working-tree-encoding=CP1252

# VBA extensions - Mark as binary
*.[fF][rR][xX]      binary

.gitconfig:

[filter "crlf"]
        clean = unix2dos
  1. Use a GitHub Action to enforce CRLF

This would be the only full proof method to maintain consitent line endings.

I think that would be a good thing to add this option to https://github.com/Vba-actions/lint-vba. I might actually have some python code I could contribute if you are interested to add this feature.

Lingua principale
VBA
Stelle
90
Fork
18
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Beakerboy/VBA-SQL-Library

Tutte le issue di Beakerboy/VBA-SQL-Library

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.