Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: angular/clang-format
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 04d945826bff21c3a74947166c69e2c6bfba95ee
Choose a base ref
...
head repository: angular/clang-format
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 41f1d0a6dae1f04ad2476daa15d989629aea373c
Choose a head ref

Commits on Apr 3, 2018

  1. refactor: misc refactoring

    - use ES6 sugar,
    - split utility functions,
    - format the code with clang-fromat!
    vicb authored and mprobst committed Apr 3, 2018
    Copy the full SHA
    219623a View commit details
  2. Copy the full SHA
    797c0fa View commit details
  3. feat: expose getNativeBinary

    Returns the platform specific path to the clang-format executable
    vicb authored and mprobst committed Apr 3, 2018
    Copy the full SHA
    b25cd8d View commit details

Commits on Aug 5, 2018

  1. Copy the full SHA
    a8ad7a6 View commit details
  2. rel: 1.2.4.

    mprobst committed Aug 5, 2018
    Copy the full SHA
    93dad46 View commit details

Commits on Jan 8, 2019

  1. Fail loudly when clang-format is unavailable

    Without this change, if clang-format is not available for the current
    platform (e.g. android_x64), running this tool has no output and exits
    with status 0. If clang-format is used to filter files, it would
    effectively empty the file.
    
    After this change, clang-format will fail with status 1 and an error
    message to stderr.
    lutzky authored and mprobst committed Jan 8, 2019
    Copy the full SHA
    245ffa6 View commit details

Commits on Jan 21, 2019

  1. build: switch to circleci

    devversion authored and mprobst committed Jan 21, 2019
    Copy the full SHA
    a072e2a View commit details
  2. build: specify version of circleci config

    Follow-up that makes this config more explicit and hides a CircleCI warning saying that the version field is missing.
    devversion authored and mprobst committed Jan 21, 2019
    Copy the full SHA
    fc32c40 View commit details

Commits on Mar 18, 2019

  1. fix: check-clang-format not working on windows

    Currently when someone runs the "check-clang-format"
    binary from the "clang-format" package on Windows, the
    script will always fail. This is because on Windows, the
    shebang cannot be read, and only the "PATHEXT" environment
    variable is respected. Therefore we can just explicitly
    declare that we want to run the "python" executable in the
    "PATH" environment variable. This ensures that the Python
    script can be launched properly on windows.
    devversion authored and mprobst committed Mar 18, 2019
    Copy the full SHA
    1317a87 View commit details

Commits on Dec 5, 2019

  1. Copy the full SHA
    4e075c1 View commit details

Commits on Jan 27, 2020

  1. build: update build.sh.

    Adjust to new llvm-project git project layout.
    Fix some outdated hostname.
    mprobst committed Jan 27, 2020
    Copy the full SHA
    c28c014 View commit details
  2. Copy the full SHA
    923f7e8 View commit details
  3. rel: 1.3.0.

    mprobst committed Jan 27, 2020
    Copy the full SHA
    c506116 View commit details
  4. build: do not use zlib on linux.

    It cannot be statically linked, and it is not actually needed by
    clang-format.
    mprobst committed Jan 27, 2020
    Copy the full SHA
    f5b2fda View commit details
  5. feat: new binaries.

    From latest master, around 8a6b948eb59267736a34a5deace9c7d947c63492.
    mprobst committed Jan 27, 2020
    Copy the full SHA
    30cf98e View commit details
  6. rel: 1.4.0

    mprobst committed Jan 27, 2020
    Copy the full SHA
    8692057 View commit details

Commits on Dec 14, 2020

  1. Copy the full SHA
    ea44b58 View commit details

Commits on Aug 4, 2021

  1. Copy the full SHA
    00e71e4 View commit details

Commits on Aug 11, 2021

  1. build(deps): bump path-parse from 1.0.6 to 1.0.7

    Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
    - [Release notes](https://github.com/jbgutierrez/path-parse/releases)
    - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)
    
    ---
    updated-dependencies:
    - dependency-name: path-parse
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and mprobst committed Aug 11, 2021
    Copy the full SHA
    eca4ddc View commit details

Commits on Aug 31, 2021

  1. Set up Github Actions CI

    mprobst authored Aug 31, 2021
    Copy the full SHA
    0e04d88 View commit details
  2. Remove CircleCI leftovers.

    mprobst committed Aug 31, 2021
    Copy the full SHA
    e9075b5 View commit details

Commits on Oct 25, 2021

  1. doc: fix build script for linux

    RaisinTen authored and mprobst committed Oct 25, 2021
    Copy the full SHA
    2541066 View commit details

Commits on Nov 5, 2021

  1. rel: 1.5.0

    mprobst committed Nov 5, 2021
    Copy the full SHA
    2026be6 View commit details
  2. Copy the full SHA
    6ac990d View commit details
  3. Copy the full SHA
    3541fe6 View commit details
  4. rel: 1.6.0

    mprobst committed Nov 5, 2021
    Copy the full SHA
    02ecb76 View commit details

Commits on Feb 14, 2022

  1. feat: default to python3 in check-clang-format

    Python 2 is no longer supported and some distributions (such as Ubuntu
    20.04) ship without a working Python 2 interpreter. The Python
    git-clang-format script works with both Python 2 and Python 3, so
    this changes the check-clang-format.js script to test for Python
    availability and choose Python 3 if available.
    jstuder-gh authored and mprobst committed Feb 14, 2022
    Copy the full SHA
    96ae673 View commit details

Commits on Apr 11, 2022

  1. chore: remove yarn.lock

    yarn.lock is older than package-lock.json.
    
    Fixes: #75
    Trott authored and mprobst committed Apr 11, 2022
    Copy the full SHA
    354dc49 View commit details

Commits on Apr 13, 2022

  1. fix: update async from 1.5.2. to 3.2.3

    This resolves an `npm audit` warning experienced by end users.
    Trott authored and mprobst committed Apr 13, 2022
    Copy the full SHA
    750782b View commit details
  2. feat: Mac & Linux binaries based on 596752863e27.

    Windows binaries to come in a subsequent commit.
    mprobst committed Apr 13, 2022
    3
    Copy the full SHA
    884663e View commit details
  3. feat: print the git hash.

    git-svn integration is no longer used, so there are no more revisions.
    mprobst committed Apr 13, 2022
    Copy the full SHA
    53a23b8 View commit details
  4. Copy the full SHA
    17ade50 View commit details
  5. 1.7.0

    mprobst committed Apr 13, 2022
    Copy the full SHA
    fa4532a View commit details

Commits on Apr 29, 2022

  1. Make sure to build x86_64 binaries on Mac.

    On the new ARM64 Macs, the default target architecture is ARM64. However ARM64 binaries only run on those new Macs, whereas the x86_64 run on both newer and older Macs.
    
    The longer term fix might be to have both an x86_64 and a darwin_arm64 binary.
    mprobst committed Apr 29, 2022
    Copy the full SHA
    f0df2e6 View commit details
  2. Copy the full SHA
    140dcf5 View commit details
  3. rel: 1.8.0.

    mprobst committed Apr 29, 2022
    Copy the full SHA
    41f1d0a View commit details
Showing with 380 additions and 150 deletions.
  1. +23 −0 .github/workflows/node.js.yml
  2. +0 −4 .travis.yml
  3. +11 −4 README.md
  4. +28 −12 bin/check-clang-format.js
  5. BIN bin/darwin_x64/clang-format
  6. +94 −43 bin/git-clang-format
  7. BIN bin/linux_x64/clang-format
  8. BIN bin/win32/clang-format.exe
  9. +22 −27 build.sh
  10. +94 −52 index.js
  11. +103 −0 package-lock.json
  12. +5 −8 package.json
23 changes: 23 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/angular/clang-format.svg?branch=master)](https://travis-ci.org/angular/clang-format)
[![Build Status](https://github.com/angular/clang-format/actions/workflows/node.js.yml/badge.svg)](https://github.com/angular/clang-format/actions/workflows/node.js.yml)

# clang-format
node.js module which wraps the native clang-format executable.
@@ -15,8 +15,10 @@ the latest upstream clang sources, make sure it is stripped and optimized
## Checking formatting

Ensuring that changes to your code are properly formatted is an important part
of your development workflow. We recommend using a git pre-commit hook. You can
configure this as follows:
of your development workflow. Note that the `check-clang-format` and
`git-clang-format` commands require Python to be globally available.

We recommend using a git pre-commit hook. You can configure this as follows:

1. add a `precommit` script to your package.json file:

@@ -68,8 +70,13 @@ See [node-glob](https://github.com/isaacs/node-glob) for globbing semantics.

For Linux, compile a statically linked MinSizeRel build:

cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_BUILD_STATIC=true ..
git clone --depth=1 https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DLLVM_BUILD_STATIC=true -DLLVM_ENABLE_PROJECTS=clang ../llvm
ninja clang-format
strip bin/clang-format

For Mac OS X, static linking is not required.

40 changes: 28 additions & 12 deletions bin/check-clang-format.js
Original file line number Diff line number Diff line change
@@ -13,17 +13,24 @@
const spawn = require('child_process').spawnSync;
const path = require('path');

function getPythonInterpreter() {
const interpreterOptions = ['python3', 'python', 'python2'];
for (const opt of interpreterOptions) {
const result = spawn(opt, ['--version'], {encoding: 'utf-8'});
if (result.status === 0) {
return opt;
}
}
return null;
}

function checkGitConfig() {
const spawn_opts = {encoding: 'utf-8', stdio: ['pipe', 'pipe', 'inherit']};
const binary =
spawn('git', ['config', '--get', 'clangFormat.binary'], spawn_opts)
.stdout.trim();
const style =
spawn('git', ['config', '--get', 'clangFormat.style'], spawn_opts)
.stdout.trim();
var gitConfigWrong = false;
const binary = spawn('git', ['config', '--get', 'clangFormat.binary'], spawn_opts).stdout.trim();
const style = spawn('git', ['config', '--get', 'clangFormat.style'], spawn_opts).stdout.trim();
let gitConfigWrong = false;

if (binary !== 'node_modules/.bin/clang-format') {
if (binary.indexOf(`node_modules${path.sep}.bin${path.sep}clang-format`) === -1) {
console.error(`
ERROR: Found git config --get clangFormat.binary = "${binary}"
This can result in running a different version of clang-format than your
@@ -47,21 +54,30 @@ function checkGitConfig() {
}

function main(args) {
let clangFormatPath;
let configCheck;

const interpreter = getPythonInterpreter();
if (interpreter === null) {
console.error('No python interpreter found');
return 2;
}

try {
var clangFormatPath = path.dirname(require.resolve('clang-format'));
var configCheck = checkGitConfig();
clangFormatPath = path.dirname(require.resolve('clang-format'));
configCheck = checkGitConfig();

if (configCheck !== 0) return configCheck;
} catch (e) {
// When running the git-clang-format on ourselves, it's located in a
// different place
var clangFormatPath = '.';
clangFormatPath = '.';
// And we don't run the configCheck, because the clang-format binary is also
// in a different place
}

const gitClangFormatPath = path.join(clangFormatPath, 'bin/git-clang-format');
const result = spawn(gitClangFormatPath, ['--diff'], {encoding: 'utf-8'});
const result = spawn(interpreter, [gitClangFormatPath, '--diff'], {encoding: 'utf-8'});

if (result.error) {
console.error('Error running git-clang-format:', result.error);
Binary file modified bin/darwin_x64/clang-format
Binary file not shown.
Loading