<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Even,<div class="">Thanks for the pointer to pre-commit!<div class=""><br class=""></div><div class=""><br class=""></div><div class="">All,</div><div class=""><br class=""></div><div class="">The complete GRASS source is now formatted with ClangFormat using the settings of the added ‘.clang-format’ file.</div><div class=""><br class=""></div><div class="">I have also added a '.pre-commit-config.yaml’, which facilitates the convenient use of ‘pre-commit’ [1].</div><div class=""><br class=""></div><div class="">The pre-commit hooks now supported are:</div><div class="">-  clang-format (for C, C++, JavaScript, JSON, Objective-C)</div><div class="">-  trailing-whitespace</div><div class="">-  end-of-file-fixer</div><div class=""><div class="">-  markdownlint</div><div class="">-  black</div><div class="">-  flake8</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">For all developers, I **strongly recommend** installing and using pre-commit. It makes life so much easier and unloads considerable amount of unnecessary work on the CI runners (oh, Black failed, now ClangFormat too, push again…).</div><div class=""><br class=""></div><div class="">The submitting guides on the wiki has been converted to markdown and are awaiting the final destination in source repo [2]. After merge they need to be updated accordingly to latest developments.</div><div class=""><br class=""></div><div class="">The question now is, are there any objections to do the same treatment to grass-addons)?</div><div class="">There are three PRs in-store [3-5] to make that happen.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Nicklas</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">[1] <a href="https://pre-commit.com" class="">https://pre-commit.com</a></div><div class="">[2] <a href="https://github.com/OSGeo/grass/pull/2765" class="">https://github.com/OSGeo/grass/pull/2765</a></div><div class="">[3] <a href="https://github.com/OSGeo/grass-addons/pull/852" class="">https://github.com/OSGeo/grass-addons/pull/852</a></div><div class="">[4] <a href="https://github.com/OSGeo/grass-addons/pull/853" class="">https://github.com/OSGeo/grass-addons/pull/853</a></div><div class="">[5] <a href="https://github.com/OSGeo/grass-addons/pull/854" class="">https://github.com/OSGeo/grass-addons/pull/854</a><br class=""><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On 2 Jan 2023, at 19:44, Even Rouault <<a href="mailto:even.rouault@spatialys.com" class="">even.rouault@spatialys.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
  
  <div class=""><p class="">I'd suggest you use pre-commit so that clang-format is
      automatically run on git commit operations like we have done with
      GDAL. Then it is a no-brainer to do changes.<br class="">
    </p><p class="">You need to add a .pre-commit-config.yaml at the root of the
      repository (<span class="pl-s">only the part referencing
        clang-format at
        <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml#L30">https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml#L30</a>
        is relevant for you)</span>:<br class="">
    </p><p class=""><a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml">https://github.com/OSGeo/gdal/blob/master/.pre-commit-config.yaml</a></p><p class="">Once that file is in place:<br class="">
    </p><p class="">-  "pip install pre-commit" : just once</p><p class="">- "pre-commit install": just once per repository</p><p class="">Cf <a class="moz-txt-link-freetext" href="https://gdal.org/development/dev_practices.html#commit-hooks">https://gdal.org/development/dev_practices.html#commit-hooks</a></p><p class="">Even<br class="">
    </p>
    <div class="moz-cite-prefix">Le 02/01/2023 à 19:20, Nicklas Larsson
      via grass-dev a écrit :<br class="">
    </div>
    <blockquote type="cite" cite="mid:C9C90726-AC48-4DF2-B7BF-C6A284173AD2@yahoo.com" class="">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class="">
      Markus,
      <div class=""><br class="">
        <div class=""><br class="">
          <blockquote type="cite" class="">
            <div class="">On 2 Jan 2023, at 13:48, Markus Neteler <<a href="mailto:neteler@osgeo.org" class="moz-txt-link-freetext" moz-do-not-send="true">neteler@osgeo.org</a>>
              wrote:</div>
            <br class="Apple-interchange-newline">
            <div class="">
              <div class="">Hi Nicklas,<br class="">
                <br class="">
                On Wed, Dec 21, 2022 at 9:25 PM Nicklas Larsson via
                grass-dev<br class="">
                <<a href="mailto:grass-dev@lists.osgeo.org" class="moz-txt-link-freetext" moz-do-not-send="true">grass-dev@lists.osgeo.org</a>>
                wrote:<br class="">
                <blockquote type="cite" class=""><br class="">
                  I understand there is agreement on using the
                  .clang-format formatting rules suggested with [1],
                  which I just merged.<br class="">
                  <br class="">
                  I have formatted the whole source base with
                  clang-format v.15.0.6, in 7 different PRs [2-8]. I
                  will start merging them tomorrow if there are no
                  objections.<br class="">
                  <br class="">
                  I have also filed a PR [9] which adds a CI check for
                  clang-format errors.<br class="">
                </blockquote>
                <br class="">
                Thanks for your efforts on the code reformatting!<br class="">
              </div>
            </div>
          </blockquote>
          <div class=""><br class="">
          </div>
          <div class="">:-)</div>
          <br class="">
          <blockquote type="cite" class="">
            <div class="">
              <div class=""><br class="">
                <blockquote type="cite" class="">Installing clang-format
                  is perhaps most easily done with:<br class="">
                  python -m pip install 'clang-format==15.0.6'<br class="">
                  <br class="">
                  Formatting may be done with something like (following
                  works on Mac):<br class="">
                  find -E . -regex '.*\.(cpp|hpp|c|h)' -exec
                  clang-format -i {} \+<br class="">
                </blockquote>
                <br class="">
                ... it fails on Linux, though<br class="">
                <br class="">
                find: unknown predicate `-E')<br class="">
              </div>
            </div>
          </blockquote>
          <div class=""><br class="">
          </div>
          <div class=""><br class="">
          </div>
          <div class="">I was pretty sure this would deviate from Mac/BSD on
            Linux systems:</div>
          <div class=""><br class="">
          </div>
          <div class=""><br class="">
          </div>
          <div class="">Try something like (untested):</div>
          <div class=""><br class="">
          </div>
          <div class="">find . -regex '.*\.(cpp|hpp|c|h)' -exec clang-format -i
            {} <span style="color: var(--black-800); font-family:
              var(--ff-mono); font-size: var(--_pr-code-fs); font-style:
              inherit; font-variant-caps: inherit; white-space:
              inherit;" class="">\;</span></div>
          <div class=""><br class="">
          </div>
          <div class="">or manually with:</div>
          <div class="">clang-format -I <file></div>
          <div class=""><br class="">
          </div>
          <br class="">
          <blockquote type="cite" class="">
            <div class="">
              <div class=""><br class="">
                <blockquote type="cite" class="">Contribution rules must
                  be updated, I will start putting up a draft ASAP.<br class="">
                </blockquote>
                <br class="">
                I am trying to fix the conflicts in<br class="">
                <a href="https://github.com/OSGeo/grass/pull/2684" class="moz-txt-link-freetext" moz-do-not-send="true">https://github.com/OSGeo/grass/pull/2684</a><br class="">
                <br class="">
                Conflicting files:<br class="">
                <br class="">
                include/grass/iostream/mm.h<br class="">
                lib/db/dbmi_base/dbmscap.c<br class="">
                lib/external/ccmath/ccmath.h<br class="">
                lib/gis/spawn.c<br class="">
                lib/gis/user_config.c<br class="">
                lib/iostream/rtimer.cpp<br class="">
                lib/pngdriver/graph_set.c<br class="">
                lib/rst/interp_float/point2d.c<br class="">
                raster/r.terraflow/filldepr.cpp<br class="">
                raster/r.terraflow/flow.cpp<br class="">
                raster/r.terraflow/main.cpp<br class="">
                raster/r.viewshed/statusstructure.cpp<br class="">
                <br class="">
                The reason will be the missing clang-format update which
                I don't know<br class="">
                how to apply on Linux.<br class="">
              </div>
            </div>
          </blockquote>
          <div class=""><br class="">
          </div>
          <div class="">Not quite sure what you mean. Did you try:</div>
          <div class=""><br class="">
          </div>
          <div class="">python -m pip install 'clang-format==15.0.6’</div>
          <div class=""><br class="">
          </div>
          <div class="">But I suspect any version 15 will do, perhaps even v. 14.</div>
          <div class=""><br class="">
          </div>
          <div class=""><br class="">
          </div>
          <div class="">A tip to use the .clang-format file from main for
            branches without it:</div>
          <div class=""><br class="">
          </div>
          <div class="">1. git checkout main</div>
          <div class="">2. cp .clang-forrmat ../.clang-format</div>
          <div class="">3. check out branch</div>
          <div class="">4. clang-format searches upwards in dir hierarchy  for
            next ‘.clang-format’ file</div>
          <div class="">5. run clang-format from grass source dir</div>
          <div class=""><br class="">
          </div>
        </div>
        <br class="">
      </div>
      <br class="">
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
grass-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/grass-dev">https://lists.osgeo.org/mailman/listinfo/grass-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com/">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

</div></blockquote></div><br class=""></div></div></div></body></html>