I'm wanting to automate a local server to pull github repositories and then add copyrights to the code files, if they aren't already there, then commit and push them back. I have the copyright executable running on the linux centOS server, but I can't get a way to tell my program to run or not. Webhooks don't work since its a local server, not web-facing, any ideas?
My first thought is that you could write a script to do this. The easiest would be to use a shell script or a python script.
The script could do the following.
Open every directory
for each directory
for each file in the directory
if not contains copyright
add copyright to top of file
git commit -m "add copyright"
git push
Related
There is a server running and has a git instance on it. I want a script to run everytime a user does git push to the server. I want my script to be executed then git push to continue.
Any work arounds?
You've tagged this GitHub so I'm assuming that you are referring to public GitHub and not GitHub enterprise.
You cannot run a script "server-side" on GitHub's servers because that would obviously be a massive vulnerability but you can set up a web hook to trigger a script on another server.
Basically whenever someone does a push, a specific URL will be sent data about the push. You can then trigger a script from this. For more information on web hooks, see the GitHub API docs.
I am not sure If you want a scipt to run prior to push or after. So here is my answer for pre-push. But if you want post-push (i.e after push) you have to change the pre-push hooks accordingly to check if pushed successfully and then you can do post push thing.
As suggested by #Travis, git hooks is the one that you are looking for. So to execute a script pre-push, you have to do is to create a pre-push file in the .git/hooks. So in this case put your bunch of code in the pre-post script file .git/hooks/pre-push and save it. Then make it executable by chmod +x .git/hooks/pre-push. After you done with this successfully you will be able to see the script gets executed each time you do run push command.
PS: Please note that I haven't tested this whole but expected to work in this way.
In Short, assuming you(Linux user) are in the project directory
vim .git/hooks/pre-push # then add your code and save the file
# Also put the shebang on top to identify the interpreter
chmod +x .git/hooks/pre-push # make it executable
You should look into git hooks:
8.3 Customizing Git - Git Hooks
and, another site regarding this technology:
githooks.com
Recently I migrated from opensuse to centos and after that GIT has started to ignore my custom commit-msg hook. It simply doesn't execute it. (I checked it by add small piece of code to "add_ChangeId" function )
Hook generates Change-Id hash for every commit
GIT version: 1.8.1.2
File is located in following location: .git/hooks/
For debugging purposes I even have set 0777 permissions to the whole .git directory
Here is the full text of commit-msg file - http://pastebin.com/zmYNi0ED
timoras you are gold. Then I tried to execute script using sh .git/hooks/scriptname it worked, but when tried to call it using .git/hooks/scriptname and shell returned that I haven't permissions to execute it.
After that I looked at fstab, and found out that have forgot to add exec flag to the partition where this file was located.
Now everything works.
One more time thanks timoras!
I use Windows 7 and also I use TortoiseSVN to keep track of my code, now I want to migrate my repository to a cloud-service and the requirement is create a *.dump file, but I can't find a way to create it. Some forums say to use "svnadmin" but I can't find it also.
My question is how can I create a *.dump file with TortoiseSVN?
TortoiseSVN ships the svnadmin utility with it. It is a command line utillity. So you will have to create a dump of your repository in the command line.
To create a dump of your repository, use
svnadmin dump C:\SVN\MyProject > C:\tmp\MyProject.dump
where C:\SVN\MyProject is the path to your SVN repo and C:\tmp\MyProject.dump is the path to the dump file, which will be created.
To import your previously made dump file into a new repository, use
svnadmin load C:\SVN\MyProject < C:\tmp\MyProject.dump
where C:\SVN\MyProject is the path to your new SVN repo and C:\tmp\MyProject.dump is the path to the dump file, which should be imported.
Subversion 1.7 now has the svnrdump command line utility.
svnrdump dump https://host/repo > repo.dump
Note that this always creates a dump with deltas, which might not be what you want.
TortoiseSVN is a svn client. It cannot take a dump of your repository. You need a tool like svnadmin on the server hosting your SVN repository to take a dump. You need access to the server and its filesystem.
Also see here for migrating a repository
svnadmin is part of the SVN server, so you should have a direct admin access to your repository server.
The first thing you need to do is follow this tutorial to get some idea about how to use TortoiseSVN on the local machine.
http://www.thinkplexx.com/learn/howto/scm/svn/how-to-create-and-use-local-svn-subversion-repository-on-windows-or-linux-simple-and-fast-step-by-step
once you have done with above tutorial and committed your files to the repository, execute below command.
svnadmin dump TortoiseRepository > dumpfile
If your TortoiseSVN repository is not called 'TortoiseRepository' just change the name above to whatever you have called it. If the dump works you should see lots of '*Dumped revision' messages. The 'dumpfile' now contains an entire export of your TortoiseSVN repository and all the revisions, comments etc.
I would like to convert a remote Perforce repository into a Mercurial repository on Linux.
So I have installed Python and Mercurial on a Linux box.
Then I test few hg (Mercurial's drive program) commands. All are working fine.
Now without creating any hg repository on the Linux box I want to run hg convert on Linux, so that a Mercurial repository (of a Perforce repository) will be created on it.
But when I tried the "hg convert" command it was not working. I know "convert" extension needs to be configured in the .hgrc file. But I don't have any hg repositories here.
Is there any any place on Linux where
I can create hgrc file with convert
extension so that hg convert command will be
accessible for me?
or
Should I first create a hg init
hgrepo on Linux and then edit .hg/hgrc file with
proper configurations and then perform
hg convert //perforce repo/.. /root/hgrepo on hgrepo?
What can I do to resolve this issue?
Place your .hgrc in your home directory, see the manual: hgrc
I'm trying to switch from a windows environment to Linux. I'm primarily PHP developer, but I do know quite a bit about other languages such as CSS, XHTML and Javascript. I need a way of editing my files locally because I work in a git repository and need to commit my saves. On windows I used Aptana and PDT. I'd save my files, upload via Aptana, then commit my work with git.
I need to get a work flow going on my Linux machine now. If you know a better way to do this let me know, however my real question is, is there a plugin that allows gedit to upload files instead of working remotely?
git was designed for distributed development and works well as a mechanism for deploying code to a web server.
On your Linux PC, git clone your git repository url. Edit and commit locally and then git push the changes to the git repository. Then, if you have shell access on the server, use git pull to copy the changes to your server.
To ftp sync, you could set up a branch, ftpbranch, that corresponds to what is on the server, and then each time you want to sync ftpbranch with master:
filestoput=`git diff --name-only master ftpbranch`
Now upload the files:
for f in $filestoput; do curl --ftp-create-dirs -T $f ftp://serverurl
Now update ftpbranch indicating these files have been copied to the server:
git checkout ftpbranch; git merge master; git checkout master
When using linux, you can mount the ftp server to a local folder, then opening and save file from that folder will automatically download and upload the file to ftp server.
If you use ubuntu, just click on Places > Connect To Server.... Choose FTP in Service Type dropdown, fill in the required info, then don't forget to bookmark it.
After this, you can open the file directly in any text editor, not just gedit. I would recoment geany for serious programming editor, because it have a lot of neat feature, almost same with Notepad++ in Windows.
But, since you already using git, why not just use git push to get the update and git pull to upload the update? I have long since uploading manually to my server. Git do all the work for me, synchronizing it between servers. Any particular reason why you still need ftp?