In this section we discuss the Yioop issue tracker and discuss using the git version control system to make and apply patches for Yioop.
- If you would like to contribute code to Yioop, but don't yet have an account on the issue tracker, you can sign up for an account.
- After one has an account and is logged in, one can click the Report Issue link to report an issue. Be sure to fill in as many report fields and give as much detail as possible. In particular, you should select a Product Version.
- The Upload File fieldset lets you upload files to an issue and the Add Note fieldset allows you to add new notes. This is where you could upload a patch. By default, a new account is a Reporter level account. This won't let you set people to moniter (get email about) the issue besides yourself. However, the administrator will be aware the issue was created.
- A developer level account will allow you to change the status of issues, update/delete issues, set who is monitoring an issue, and assign issues to individuals. This can be done through the fieldset just beneath Attached Files.
- Information about Git, Git clients, etc. can be obtained from: http://git-scm.com/. Here we talk about a typically workflow for coding Yioop using Git.
- After installing git, make sure to configure your user name and email address:
% git config --global user.name "Chris Pollett"
% git config --global user.email "chris@pollett.org"
You should of course change the values above to your name and email. To see your current configuration settings you can type:
% git config -l
If you want to remove any settings you can type:
% git config --unset some.setting.you.dont.want
Setting the user name and email will ensure that you receive credit/blame for any changes that end up in the main git repository. To see who is responsible for what lines in a file one can use the git blame command. For example:
% git blame yioopbar.xml
|chris-polletts-macbook-pro:yioop:526>git blame yioopbar.xml
git blame yioopbar.xml
ad3c397c (Chris Pollett 2010-12-28 00:27:38 -0800 1) <?xml version="1.0" e
ad3c397c (Chris Pollett 2010-12-28 00:27:38 -0800 2) <OpenSearchDescriptio
ad3c397c (Chris Pollett 2010-12-28 00:27:38 -0800 3) <ShortName>Yioop<
ad3c397c (Chris Pollett 2010-12-28 00:27:38 -0800 4) <Description>Quickly
ad3c397c (Chris Pollett 2010-12-28 00:27:38 -0800 5) <InputEncoding>UTF-8
ad3c397c (Chris Pollett 2010-12-28 00:27:38 -0800 6) <Image width="16" hei
774eb50d (Chris Pollett 2012-12-31 10:47:57 -0800 7) <Url type="text/html"
774eb50d (Chris Pollett 2012-12-31 10:47:57 -0800 8) template="http://
ad3c397c (Chris Pollett 2010-12-28 00:27:38 -0800 9) </Url>
774eb50d (Chris Pollett 2012-12-31 10:47:57 -0800 10) </OpenSearchDescripti
- To make a new copy of the most recent version of Yioop one can run the git clone command:
% git clone https://seekquarry.com/git/yioop.git yioop
This would create a copy of the Yioop repository into a folder yioop in the current directory. Thereafter, to bring this copy up to date with the most recent version of yioop one can issue the command:
% git pull
- Once one has a git clone of Yioop -- or done a git pull of the most recent changes to Yioop -- one can start coding! After coding a while you should run git status to see what files you have changed. For example,
% git status
# On branch master
# Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# tmp.php
nothing added to commit but untracked files present (use "git add" to track)
This says there has been one commit to the main repository since your clone / last git pull. It also says we could bring things up to date by just doing a git pull. In this case, however, it says that there was an untracked file in the repository. If this file was a file we made with the intention of adding it to Yioop, we should type git add to add it. For example,
% git add tmp.php
Now we could try to do a git pull. Suppose we get the message...
Updating e3e4f20..a9a8ed9
error: Your local changes to the following files would be overwritten by merge:
tmp.php
Please, commit your changes or stash them before you can merge.
Aborting
What this means is that someone else has also added tmp.php and there are conflicts between these two versions. To merge these two versions, we first commit our version:
% git commit -a -m "Fixes Issue 987, Yioop needs a tmp.php file, a=chris"
[master 3afe055] Fixes Issue 987, Yioop needs a tmp.php file, a=chris
1 file changed, 4 insertions(+)
create mode 100644 tmp.php
The option -a tells git to put in the commit all changes done to staged files (those that we have git add'd) since the last commit. The option -m is used to give an inline message. The general format of a of such a message in Yioop is: which issue number in the issue tracker is being fixed, a brief English summary of that issue, and under whose authority the commit is being done. This last will be in the format a=chris where a means approved and the person who approved is of sufficient seniority to commit unreviewed things or in the format r=someone, where someone is the person asked in the issue to review your commits before they are pushed. Often for administrator commits, there won't be an associated issue tracking issue, in which case the format reduces to: some useful English description of the change, a=username of administrator. Now that we have done the above commit, we can try again to do a git pull:
% git pull
Auto-merging tmp.php
CONFLICT (add/add): Merge conflict in tmp.php
Automatic merge failed; fix conflicts and then commit the result.
%cat tmp.php
cat tmp.php
<?php
<<<<<<< HEAD
echo "hello";
echo "good bye";
=======
>>>>>>> a9a8ed990108598d06334e29c0eb37d98f0845aa
?>
The listing of the tmp.php file above has blocks of the form: <<<<<<< HEAD, =======, >>>>>>> a9a8ed990108598d06334e29c0eb37d98f0845aa. In this case, there is only one such block, in general, there could be many. The stuff before the ======= in the block is in the local repository, the stuff after the ======= is in the remote repository. So in the local copy, there are the two lines:
echo "hello";
echo "good bye";
not in the remote repository. On the other hand, there is nothing in the remote repository not in the local copy. So we could fix this conflict by editing this block to look like:
<?php
echo "hello";
echo "good bye";
?>
In general, we should fix each conflict block if there is more than one. Conflicts can also be in more than one file, so we could have to fix each file with conflicts. Once this is done, to tell git we have resolved the conflict, we can type:
% git add tmp.php
% git commit
[master e5ebf9f] Merge branch 'master' of https://seekquarry.com/git/yioop
Here we didn't use -m, so we were dropped into the vi text editor, where we left the default commit message. Now we can go back to editing our local copy of Yioop. If we do a git pull at this point, we will get the message: "Already up-to-date."
- The "opposite command" to git pull is git push. Most casual developers for Yioop don't have push privileges on the main Yioop repository. If one did, a possible development workflow would be: Pull the master copy of Yioop to a local branch, make your changes and post a patch to the Bug/Issue in question on the issue tracker asking someone to review it (probably, the administrator, which is me, Chris Pollett). The reviewer gives a thumbs up or down. If it is a thumbs up, you push your changes back to the master branch. Otherwise, you revise you patch and try again. To configure git so git push works you can either make a ~/.netrc file with
machine seekquarry.com
login <username>
password <password>
in it, chmod it to 600, and type:
% git config remote.upload.url https://seekquarry.com/git/yioop.git
or you can just type the command:
% git config remote.upload.url \
https://<username>@seekquarry.com/git/yioop.git
After this, you should be able to use the command:
% git push upload master
This pushes your local changes back to the repository. In the second method, you will be prompted for your password. Another common setting that you might to change is http.sslVerify. If you are getting error messages such as
error: server certificate verification failed. CAfile:
/etc/ssl/certs/ca-certificates.crt CRLfile: none
while accessing https://seekquarry.com/git/yioop.git/info/refs
you might want to use the command:
% git config --global --add http.sslVerify false
- In the workflow above, the changes we make to our local repository should be reviewed before we do a push back to the Yioop repository. To do this review, we need to make a patch, upload the patch to the issue tracker, and add someone to this issue monitor list who could review it, asking them to do a review. These last two steps require the user to have at least a developer account on the issue tracker. Anyone who registers for the issue tracker gets initially a reporter account. If you would like to code for Yioop and have already made a patch, you can send an email to chris@pollett.org to request your account to be upgraded to a developer account. New developers do not get push access on the Yioop repository. For such a developer, the workflow is create a patch, post it to an issue on the issue tracker, get it approved by an administrator reviewer, then the reviewer pushes the result to the main Yioop repository.
- After coding, but before making a patch you should run executables/CodeTool.php to remove any stray tab characters, or spaces at the end of lines. This program can be run either on a single file or on a folder. For example, one could type:
% php executables/CodeTool.php clean tmp.php
This assumes you were in the Yioop base directory and that was also the location of tmp.php. You should also run the command:
% php executables/CodeTool.php longlines tmp.php
to check for lines over 80 characters.
- To make a patch, we start with an up-to-date copy of Yioop obtained by either doing a fresh clone or by doing a git pull. Suppose we create a couple new files, add them to our local repository, do a commit, delete one of these files, make a few more changes, and commit the result. This might look on a Mac or Linux system like:
% ed test1.php
test1.php: No such file or directory
a
<?php
?>
.
wq
9
% ed test2.php
test2.php: No such file or directory
a
<?php
?>
.
wq
9
% git add test1.php
% git add test2.php
% git commit -a -m "Adding test1.php and test2.php to the repository"
[master 100f787] Adding test1.php and test2.php to the repository
2 files changed, 4 insertions(+)
create mode 100644 test1.php
create mode 100644 test2.php
% ed test1.php
9
1
<?php
a
phpinfo();
.
wq
24
% git rm test2.php
rm 'test2.php'
% ls
./ README* data/ locale/ search_filters/
../ bin/ error.php* models/ test1.php
.DS_Store* blog.php* examples/ my.patch tests/
.git/ bot.php* extensions/ privacy.php* views/
.gitignore configs/ favicon.ico resources/ yioopbar.xml
INSTALL* controllers/ index.php* robots.txt
LICENSE* css/ lib/ scripts/
% git commit -a -m "Adding phpinfo to test1.php, removing test2.php"
[master 7e64648] Adding phpinfo to test1.php, removing test2.php
2 files changed, 1 insertion(+), 2 deletions(-)
delete mode 100644 test2.php
Presumably, you will use a less ancient editor than ed. ed though does have the virtue of not clearing the screen, making it easy to cut and paste what we did. We now want to make a patch consisting of all the commits since we did the git pull. First, we get the name of the commit before we started modifying stuff by doing git log -3 to list out the information about the last three commits. If you had done more commits or less commits since the git pull then -3 would be different. We see the name is e3e4f20674cf19cf5840f431066de0bccd1b226c. The first eight or so characters of this uniquely identify this commit, so we copy them. To make a patch with git, one uses the format-patch command. By default this will make a separate patch file for each commit after the starting commit we choose. To instead make one patch file we use the --stdout option and redirect the stream to my.patch. We can use the cat command to list out the contents of the file my.patch. This sequence of commands looks like the following...
% git log -3
commit 7e646486faa35f69d7322a8e4fca12fb6b457b8f
Author: Chris Pollett <chris@pollett.org>
Date: Tue Jan 1 17:32:00 2013 -0800
Adding phpinfo to test1.php, removing test2.php
commit 100f7870221d453720c90dcce3cef76c0d475cc8
Author: Chris Pollett <chris@pollett.org>
Date: Tue Jan 1 16:35:02 2013 -0800
Adding test1.php and test2.php to the repository
commit e3e4f20674cf19cf5840f431066de0bccd1b226c
Author: Chris Pollett <chris@pollett.org>
Date: Tue Jan 1 15:48:34 2013 -0800
modify string id in settings_view, remove _REQUEST variable from
machinelog_element, a=chris
% git format-patch e3e4f2067 --stdout > my.patch
% cat my.patch
From 100f7870221d453720c90dcce3cef76c0d475cc8 Mon Sep 17 00:00:00 2001
From: Chris Pollett <chris@pollett.org>
Date: Tue, 1 Jan 2013 16:35:02 -0800
Subject: [PATCH 1/2] Adding test1.php and test2.php to the repository
---
test1.php | 2 ++
test2.php | 2 ++
2 files changed, 4 insertions(+)
create mode 100644 test1.php
create mode 100644 test2.php
diff --git a/test1.php b/test1.php
new file mode 100644
index 0000000..acb6c35
--- /dev/null
+++ b/test1.php
@@ -0,0 +1,2 @@
+<?php
+?>
diff --git a/test2.php b/test2.php
new file mode 100644
index 0000000..acb6c35
--- /dev/null
+++ b/test2.php
@@ -0,0 +1,2 @@
+<?php
+?>
--
1.7.10.2 (Apple Git-33)
From 7e646486faa35f69d7322a8e4fca12fb6b457b8f Mon Sep 17 00:00:00 2001
From: Chris Pollett <chris@pollett.org>
Date: Tue, 1 Jan 2013 17:32:00 -0800
Subject: [PATCH 2/2] Adding phpinfo to test1.php, removing test2.php
---
test1.php | 1 +
test2.php | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)
delete mode 100644 test2.php
diff --git a/test1.php b/test1.php
index acb6c35..e2b4c37 100644
--- a/test1.php
+++ b/test1.php
@@ -1,2 +1,3 @@
<?php
+ phpinfo();
?>
diff --git a/test2.php b/test2.php
deleted file mode 100644
index acb6c35..0000000
--- a/test2.php
+++ /dev/null
@@ -1,2 +0,0 @@
-<?php
-?>
--
1.7.10.2 (Apple Git-33)
- One should always list out the patch as we did above before posting it to the issue tracker. It can happen that we accidentally find that we have more things in the patch than we should. Also, it is useful to do one last check that the Yioop coding guidelines seem to be followed within the patch.
- The last step before uploading the patch to the issue tracker is to just check that the patch in fact works. To do this make a fresh clone of Yioop. Copy my.patch into your clone folder. To see what files the patch affects, we can type:
% git apply --stat my.patch
test1.php | 2 ++
test2.php | 2 ++
test1.php | 1 +
test2.php | 2 --
4 files changed, 5 insertions(+), 2 deletions(-)
Since there are two concatenated patches in my.patch, it first lists the two files affected by the first patch, then the two files affected by the second patch. To do a check to see if the patch will cause any problems before applying it, one can type:
% git apply --check my.patch
Finally, to apply the patch we can type:
% git am --signoff < my.patch
Applying: Adding test1.php and test2.php to the repository
Applying: Adding phpinfo to test1.php, removing test2.php
</pre>
The am says apply from a mail, the --signoff option says to write a
commit message with your email saying you approved this commit. From
the above we see each patch within my.patch was applied in turn. To
see what this signoff looks like, we can do:
<pre>
commit aca40730c41fafe9a21d4f0d765d3695f20cc5aa
Author: Chris Pollett <chris@pollett.org>
Date: Tue Jan 1 17:32:00 2013 -0800
Adding phpinfo to test1.php, removing test2.php
Signed-off-by: Chris Pollett <chris@pollett.org>
commit d0d13d9cf3059450ee6b1b4a51db0d0fae18256c
Author: Chris Pollett <chris@pollett.org>
Date: Tue Jan 1 16:35:02 2013 -0800
Adding test1.php and test2.php to the repository
Signed-off-by: Chris Pollett <chris@pollett.org>
commit e3e4f20674cf19cf5840f431066de0bccd1b226c
Author: Chris Pollett <chris@pollett.org>
Date: Tue Jan 1 15:48:34 2013 -0800
modify string id in settings_view, remove _REQUEST variable from
machinelog_element, a=chris
At this point the patch seems good to go, so we can upload it to the issue tracker!