0

I want to edit the gitolite3`s configuration file, which is written in perl, and looks like that:

# comments

# comments

%RC = (

    # ------------------------------------------------------------------

    # comments
    UMASK                           =>  0077,

    # comments
    GIT_CONFIG_KEYS                 =>  '',

    # comments
    ROLES => {
        READERS                     =>  1,
        WRITERS                     =>  1,
    },

    # comments
    ENABLE => [

        # comments

            'help',
            'desc',
            'info',
            'perms',
            'writable',

        # comments

    ],

);

# ------------------------------------------------------------------------------
# comments
1;

# comments

If no augeas is available I need something that preserve the comments - they are very handy for me and future admins.

Adam Ryczkowski
  • 7,592
  • 13
  • 42
  • 68

1 Answers1

2

Since gitolite.rc is directly an associative array, you could consider writing your utility in perl.

src/lib/Gitolite/Rc.pm already show you how to load that file, and it provides a way to query the keys/values:

Usage: gitolite query-rc -a
gitolite query-rc [-n] [-q] rc-variable
-a print all variables and values (first level only)
-n do not append a newline if variable is scalar
-q exit code only (shell truth; 0 is success)

But you can extends those features with a way to add key/value and write the config back.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Good advise if I only knew Perl. But still - I suspect that if I am ready to skip the comments I might relatively easily do something like `dump` the modified hash back to disk. But I prefer to leave the comments intact - they are very handy for me and any future admin. That's way I turned my attention towards augeas. – Adam Ryczkowski Oct 22 '14 at 09:08