[RFC] Tools to fix/prevent broken Documentation file references

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I personally am happy with the more organized Documentation/ tree. But
as everyone knows, there's still a bit of breakage. Not the most fun
to fix. However, it seems some tools could help ease this process /
prevent future breakage. I listed a couple below. If either seem worth
pursuing, I'd be happy to take up implementing them. Else, or if
they've already been discussed, please let me know.

(1) Currently, checkpatch.pl checks for deleted/moved/added files and
asks if MAINTAINERS needs to be updated (if MAINTAINERS isn't modified
in the diff). It'd be nice to extend checkpatch.pl to, when it sees a
deleted/moved file, grep for that file name. If there are any hits,
have it be an error. Perhaps people might want this only under the
--strict flag though...

(2) Part of the process of updating references could be automated.
Here's a experimentation-quality script that uses git to find what the
file was renamed to:

    set -o pipefail

    guess_new_name() {
      old_name=$1
      git rev-list -n 1 HEAD -- "$old_name" |
        xargs -r git show |
        grep -A 1 "^rename from $old_name$" |
        tail -n 1 |
        cut -d' ' -f3-
    }

    for file in $(git ls-files | grep -v '^scripts/')
    do
      for old_name in $(grep -hoP 'Documentation/[^\s$%"*{}<>\]\[\(\)\\)]+\b' "$file")
      do
        [ -e "$old_name" ] || {
          printf '%s: %s -> ' "$file" "$old_name"
          new_name=$(guess_new_name "$old_name")
          if [ $? -eq 0 ]
          then
            echo "$new_name"
            sed -i'' "s|$old_name|$new_name|" "$file" || exit 1
          else
            echo NONE
          fi
        }
      done
    done

It works quite well. I thought it might be worth improving a little
(caching, recursively making sure the new name exists, ...?) and
putting it in the tree.

Of course, option (1) naturally works for all files, not just
Documentation/ files. Option (2) could be generic as well I guess,
with a better regex (and a longer runtime...).

Cheers,
Genki
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux