question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Howto setup file-contents-sorter

See original GitHub issue

You maybe aware of the encryption tool StackExchange/blackbox

It tracks the encrypted files in keyrings/live/blackbox-files.txt. This file soon-ish gets a merge mess up when worked on collaboratively because the tool sorts it when adding new files. Therefore, I wanted to make use of file-contents-sorter.

However, I am a bit stuck with configuring it properly. I tried many combinations. The union of all and what I consider most reasonable is

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.1.0
    hooks:
       - id: file-contents-sorter
         verbose: true
         files: 'blackbox\-files\.txt$'
         args: ['./keyrings/live/blackbox-files.txt']

Can you please direct me to the right solution here? Thanks. 💟

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
dan98765commented, Jan 25, 2019

Thanks for the ping @asottile. @xasx - we’ve been using it for the same thing you’re looking for: to sort files that are kinda generic lists to reduce merge conflicts.

Specifically, here’s one example of its entry in a .pre-commit-config.yaml in a production service repository:

repos:
...
    -   id: file-contents-sorter
        files: ^(deploy-whitelist.txt|\.gitignore|\.dockerignore)$
...
3reactions
asottilecommented, Jan 24, 2019

looks close – I think the way to configure it (read:I haven’t used it myself so I’m just basing this on the config) is as follows:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.1.0
    hooks:
       - id: file-contents-sorter
         # verbose: true (only if you need to debug it, shouln't be necessary)
         files: blackbox-files\.txt$

CC @dan98765 who might have a concrete example of using this hook somewhere

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to use pre-commit hook to sort a csv file - Stack Overflow
I found this pre-commit hook file-contents-sorter which sorts the file with the first value. repos: - repo: https://github.com/pre-commit/pre- ...
Read more >
How to sort file contents in reverse order in Ubuntu - YouTube
How to sort file contents in reverse order in Ubuntu. 197 views 6 years ago ... Getting started with Ansible 02 - SSH...
Read more >
Using Bash Sort to Sort Files Like a Boss - Adam the Automator
The sort command sorts file contents depending on the flag you'll be adding. But first, you need a file with contents you'll modify....
Read more >
How to Use the Bash Sort Command - Linux Hint
The Bash sort command is used to sort a file's content and give output in the stdout. With sort, you can sort a...
Read more >
Supported hooks - pre-commit
python-import-sorter - This hook sorts python imports. ... github.com/asottile/setup-cfg-fmt. setup-cfg-fmt - apply a consistent format to `setup.cfg` files ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found