Git Product home page Git Product logo

Comments (6)

keithc-ca avatar keithc-ca commented on May 18, 2024

It has been a week and the only feedback has been positive. @AdamBrousseau can you help make this happen? Thanks.

from openj9.

DanHeidinga avatar DanHeidinga commented on May 18, 2024

Would a .gitattribute file be a better solution? See https://stackoverflow.com/questions/10418975/how-to-change-line-ending-settings for examples of how to use the .gitattribute file to control line endings.

from openj9.

keithc-ca avatar keithc-ca commented on May 18, 2024

I never did get the result I was hoping for with .gitattributes, and I believe it depends on users configuring their local clones properly.

from openj9.

AdamBrousseau avatar AdamBrousseau commented on May 18, 2024

I can provide an automatic build that will get the list of files modified/added in a PR

FILES=($(git diff --diff-filter=ACM --name-only origin/$ghprbTargetBranch HEAD))

for filename in ${FILES[@]};
do
    # Check line endings
done

@keithc-ca can you provide the check inside the loop. I will add some bits that will collect all the bad files and print them to the console at the end of the job

from openj9.

keithc-ca avatar keithc-ca commented on May 18, 2024

I ran this over the entire openj9 repository; the files flagged are corrected by #146.

#!/bin/bash -

debug() {
  : # echo "$*"
}

error() {
  echo "$*"
}

for filename in "$@" ; do
  type=$(file -b "$filename")

  case "$type" in
    empty)
      debug "Empty file: '$filename'"
      ;;
    *text*)
      # map filename to lowercase with ',,'
      case "${filename,,}" in
        *.bat | *.cmd)
          case "$type" in
            *CRLF\ line\ terminators*)
              debug "Good windows script: '$filename' type: '$type'"
              ;;
            *)
              error "*** ERROR: should have CRLF line terminators: '$filename' type: '$type'"
              ;;
          esac
          ;;
        *)
          case "$type" in
            *CR*line\ terminators*)
              error "*** ERROR: should have LF line terminators: '$filename' type: '$type'"
              ;;
            *)
              debug "Good text file: '$filename' type: '$type'"
              ;;
          esac
          ;;
      esac
      ;;
    *)
      debug "Non-text file:'$filename' type: '$type'"
      ;;
  esac
done

from openj9.

AdamBrousseau avatar AdamBrousseau commented on May 18, 2024

@keithc-ca I have been testing this in my fork and I think its working as expected.
The temp PR for the script is here
The PR I have been testing with is here
The job is here
It launches automatically on every PR, can launch manually via Jenkins line endings check
Feel free to open a PR at my fork to test.
Please take a look. If you are satisfied, I will fix the repo variable and open a PR here.

from openj9.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.