Contributing to Projects on GitHub all You Need is a Fork

Written by James McDonald

August 1, 2014

Today I did my first attempt at committing some code to an open source project named xtuple, specifically the javascript part that supports the xtuple-mobile client https://github.com/xtuple/xtuple

After posting a query about a translation issue on the xTuple forums http://www.xtuple.org/forums/i18n-internationalization/australia-and-new-zealand/xtuple-mobile-showing-unstranslated-label the next comment basically gave me the whole answer but suggested I contribute the fix. So I did.

So the basic steps.

  1. Fork the project to my own github account
  2. Clone this repository to my local computer and configure git with my details
    git clone https://github.com/jmcd73/xtuple xtuple-jmcd73
    cd xtuple-jmcd73
    git config --global user.name "James McDonald"
    git config --global user.email [email protected]
  3. Add my github xtuple  instance as a remote
    git remote add jmcd73 [email protected]:jmcd73/xtuple.git
  4. Locally make the change to the file and commit
    # create a branch and switch to it
    git branch en_AU-fix
    git checkout en_AU-fix
    
    # do edits to file and then add and commit
    git add scripts/lib/build_dictionary.js
    git commit -m "change build_dictionary.js ... commit comment"
    
  5. push to my forked xtuple repository
    git push jmcd73 en_AU-fix
  6. Work around getting (public key) access denied issue because I didn’t have ssh-agent running locally and I had no .ssh key configured on git hub.
    # get the agent running
    eval "$(ssh-agent -s)"
    # create a key (only needed if you don't have one already)
    ssh-keygen
    # add a key
    ssh-add ~/.ssh/id_rsa
    # check it's loaded
    ssh-add -l
    2048 af:35:a8:e1:cd:d0:bc:9d:72:55:be:zz:80:bf:ed:80 /home/jmcd/.ssh/id_rsa (RSA)
    
  7. Add the contents of ~/.ssh/id_rsa.pub to github under Account Settings ==> SSH Keys
    https://help.github.com/articles/error-permission-denied-publickey
    https://help.github.com/articles/generating-ssh-keys#step-3-add-your-ssh-key-to-github
  8. Finally once you have successfully added a change to your personal fork go to the main project page and click Submit Pull Request. The parent project detects you have done the fork and committed changes so the button is prominent.
  9. Done

xtuple_contribution

Once you have the fix installed into xTuple

I did the following

cd /home/vagrant/source/xtuple

root@xtuple-server:/home/vagrant/source/xtuple# scripts/export_dictionary.js -l en_AU -d test
Exporting to /home/vagrant/source/xtuple/scripts/output/en_AU_dictionary.js
Success!

Then you will have a file en_AU_dictionary.js in scripts/output/ (you may need to mkdir scripts/output as this didn’t exist when I tried and it failed)

The file has the translation in the javascript key named target:

{
  "language": "en_AU",
  "extensions": [
    {
      "extension": "_core_",
      "strings": [
        {
          "key": "_abbreviation",
          "source": "Abbreviation",
          "target": "Abbreviation"
        },
        {
          "key": "_abbreviationLong",
          "source": "Abbreviation Long",
          "target": "Abbreviation Long"
        },
        // ...
     }
    ]
}
    

Then you just have to import it to the correct database which in my case is named test.

./scripts/import_dictionary.js -f scripts/output/en_AU_dictionary.js -d test

The code I changed is here https://github.com/jmcd73/xtuple/blob/en_AU-fix/scripts/lib/build_dictionary.js#L204

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...