1

Currently, I am tracking my repository with inotifywait. And it supports only flat files, so I created non-bare repo actually with git.

But I decided to go to Gitolite and I can’t see anything about creating non-bare repo. Is there is an option?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Andrew Gorpenko
  • 187
  • 1
  • 1
  • 10

1 Answers1

1

inotifywait waits for changes to files.

If you want to monitor changes at the server level (where gitolite operates, behind ssh), you will need to add a non-update hook, typically a post-receive one, which will checkout the bare repo somewhere monitored by inotifywait.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • So will I be able to monitor specific file with such method? – Andrew Gorpenko Jul 24 '17 at 06:21
  • @AndrewGorpenko Yes, as I mention in your other question: https://stackoverflow.com/a/45272956/6309. A post-receive hook can list the files that have been pushed: https://stackoverflow.com/a/9478883/6309 – VonC Jul 24 '17 at 06:34
  • Ohh..I am so sorry, but I can’t get in. I mean, you offered a lot of information and I got stuck. May I ask you to tell what exactly I have to do? So I have a bare repo, ok. And once somebody pushed I need inotifywait to read one file. I am using initify because I am reading config file and getting version with sed. I will appreciate your help! Thanks for being patient! – Andrew Gorpenko Jul 24 '17 at 09:27
  • @AndrewGorpenko "I can’t get in": what do you mean? Do you have access to the gitolite server where the bare repos are managed? – VonC Jul 24 '17 at 09:30
  • Okey, look. Of course I own that repo:) Today I’ve setup gitolite with some repos; modsworkspace.git, pluginsworkspace.git. In repositories directory I created test.git and executed there git Init. So as you see, modsworkspace and pluginsworkspace are bare, and test.git is not bare. – Andrew Gorpenko Jul 24 '17 at 09:54
  • 1
    @AndrewGorpenko For the bare repo add your post-receive hook as described in http://gitolite.com/gitolite/cookbook/#adding-other-non-update-hooks. For the non-bare repo, simply add the same post-receive hook in `test.git/.git/hooks/post-receive` That receive hook can check if your file is pushed (https://stackoverflow.com/a/9478883/6309). If it is, it can checkout just that one file (`git --work-tree=/tmp checkout HEAD -- name_of_file`) and make your sed. The point is, with a hook, you don't need `inotify ` – VonC Jul 24 '17 at 11:22
  • @AndrewGorpenko It is just a script, any bash script you want: read more at https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks. In your case, that script should read the files pushed, as described in https://stackoverflow.com/a/9478883/6309. – VonC Jul 24 '17 at 11:48
  • Oh gee, now I am getting into this;) Thanks for such a nice explanation! If something heppens-I will make a new question. Thanks again! – Andrew Gorpenko Jul 24 '17 at 11:52
  • @AndrewGorpenko Sure. Don't forget your other question: https://stackoverflow.com/a/45272956/6309 – VonC Jul 24 '17 at 11:56
  • Mr. @VonC , are you still here? – Andrew Gorpenko Jul 24 '17 at 16:23
  • Commuting, in a train. Be back in a few hours – VonC Jul 24 '17 at 16:23
  • I will try to ask you now. So the last question is: how can I get folder name where the file was modified? Here is the correct structure: modsworkspace.git->it contains mod1 and mod2->in each of these there is plugin.yml. So if I commit to mod2, I need to get, that the file was modified in mod2. – Andrew Gorpenko Jul 24 '17 at 20:56
  • @AndrewGorpenko Sorry, busy day. I'll answer on your other question – VonC Jul 24 '17 at 20:57
  • I have other question?:)) – Andrew Gorpenko Jul 24 '17 at 20:59
  • @AndrewGorpenko Yes, I'll answer on your new question (better than buried in a comment chain) – VonC Jul 24 '17 at 21:00
  • Oh, I forgot about what question you are talking:)) If it won’t be hard please provide link to that question, course I am retarded:)) – Andrew Gorpenko Jul 24 '17 at 21:02
  • @AndrewGorpenko No I meant: ask a new question (in which you can group your other questions as long as they are related to the same issue). I will answer there. I thought you had posted a new question today. – VonC Jul 24 '17 at 21:03
  • @AndrewGorpenko strange, I don't find your new question. Please ask a new one. – VonC Jul 24 '17 at 21:13
  • New question: https://stackoverflow.com/questions/45290215/how-can-i-make-gitolite-post-receive-hook-to-show-full-path-to-modified-file – Andrew Gorpenko Jul 24 '17 at 21:17
  • git diff –name-only does not work course it does not exist. Yep, there is no –name-only. That is because I was not using it.. – Andrew Gorpenko Jul 24 '17 at 21:22
  • @AndrewGorpenko OK, I'll see that tomorrow. – VonC Jul 24 '17 at 21:23
  • Good night!:))) – Andrew Gorpenko Jul 24 '17 at 21:25
  • @AndrewGorpenko So, what do you meant by "it does not exist"? – VonC Jul 25 '17 at 06:20
  • It was servers fault. So I've added two commands into hook: git –work-tree=/tmp checkout HEAD — plugin.yml and git diff –name-only $1..$2. And the output is: error: pathspec plugin.yml did not match any files known to git and fatal: ..:.. '..' is outside repository. I think that the problem is it does not look inside subdirectories.. – Andrew Gorpenko Jul 25 '17 at 06:39
  • @AndrewGorpenko you need to full relative path of plugin.yml, unless plugin.yml is directly under the repo root folder. And the second line has a sense only within the loop you mention in your new question https://stackoverflow.com/q/45290215/6309. Replace $1 and $2 by oldrev and newrev within that loop. – VonC Jul 25 '17 at 06:49
  • Replaced. Output: fatal: ambiguous argument oldrev..newrev: unknown revision or path not in the working tree. Use – to separate path from revisions. Hmm.. If you need, I will update code in my new question and paste full output. – Andrew Gorpenko Jul 25 '17 at 07:04
  • I tried to replace oldrev..newrev by oldrev – newrev, but this gave bad revision oldrev:) – Andrew Gorpenko Jul 25 '17 at 07:07
  • @AndrewGorpenko yes, let's switch to the new question. – VonC Jul 25 '17 at 07:10