Git Repositories
Using github
The simplest, fastest way to create a git-based repository for your project is creating a project with github .
Assuming that you (the manager of the project to be created) want to create an ohwr project with a github repository, here are the steps:
1. Project manager / Github repository admin (you)*
- Login / register on github.
- Create a new github project. It is recommended that you name the github project following Redmine's naming conventions: This is, only lowercase letters, numbers and hyphens (-), and a max length of 30 characters.
- Contact Javier Serrano indicating the github project you want to use as repository. Javier will create an ohr-support issue and assign it to the ohr-support team.
2. ohwr admin (Javier)*
- Create the project with the repository flag deactivated.
- Open a support ticket detailing:
- The project id
- The github repository url
3. ohr-support team (egarcia, fjuan)*
- Read docuemtation at plugin repository
- git clone the repository into the local repository folder
- Activate the repository flag for the project, and then go to
Settings/Repository and set the following fields:
- type of repository: git
- Path to Repository field pointing to the final /.git/ folder
- Overwrite default settings for checkout url: Yes
- Checkout url: the git:// (read-only address) for the repository on github
- Render checkout URL as a link: Yes
- Display Login: No login or password
Send the hook url to the project manager. It should look like this:
"https://www.ohwr.org/github_hook?project_id=ohwr_project_identifier".
Note that the id=
parameter is needed only if the github repository
name is different from the Ohwr project identifier.
4. Project manager / Github repository admin (you)*
- Go to your project's github page, and then to Admin / Service Hooks / Post-Receive URLs .
- Insert exactly the url that you have received. It should look like this: "https://www.ohwr.org/github_hook?project_id=ohwr_project_identifier".
- Test the hook by re-visiting the page and clicking on the "test" button.
- Official documentation: http://help.github.com/post-receive-hooks/
Note: Post-Receive Hooks looses timezone information
Using non-github servers
1. Project manager / Git admin (you)*
- Create a new git repository on your git server. It is recommended that you name the github project following Redmine's naming conventions: This is, only lowercase letters, numbers and hyphens (-), and a max length of 30 characters.
- Contact Javier Serrano indicating that repository's read-only git url. Javier will create an ohr-support issue and assign it to the ohr-support team.
Steps 2 and 3: Same as above*
4. Project manager / Git admin (you)*
* On the git server, create a new file inside
/your-git-repository/.git/hooks/post-receive
* Add the following line to that file (you will receive the correct OHWR-PROJECT-ID from the ohr-support team once your ohwr project has been created)
wget --post-data="payload={}&project_id=OHWR-PROJECT-ID" https://www.ohwr.org/github_hook
- Notice that
wget
must be available from the command line for the git user in order for this to work.
From that moment on, the git repository will be synced; new updates on the server will be automatically 'told' to the ohwr repository.
- Make sure that the file is executable by the git user.
SVN to GIT
Based on this guide: http://www.jonmaddox.com/2008/03/05/cleanly-migrate-your-subversion-repository-to-a-git-repository/
1. SSH to the host env, cd to the git repo folder and su as git:*
Notice that the git repository path might change.
ssh ohwr
cd /var/git/repositories
sudo su git
2. Create a users.txt file*
nano ~/users.txt
It must include the login, full name and address of all the committers of /trunk/ using the following format:
jmaddox = Jon Maddox <jon@gmail.com>
bigpappa = Brian Biggs <bigpappa@gmail.com>
3. Clone /trunk/ into a temp git using the users.txt file*
We'll be assuming that the name of our project is "project" here. Change as required.
mkdir project_tmp.git
cd project_tmp.git
git svn init http://svn.ohwr.org/project/trunk/ --no-metadata
git config svn.authorsfile ~/users.txt
git svn fetch
4. Clone the temp repository into a bare one*
This will make sure that no traces of SVN remain on the repo
cd ..
git clone --bare project_tmp.git project.git
5. Remove temporary folder and users.txt*
rm -rf project_tmp.git
rm ~/users.txt
6. Update repository info in OHWR site*
- Go to project / settings / repository and delete the svn repository info
- Create a new repository info with the "GIT" protocol
- Override the Git checkout settings with correct ones.