Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Submitting your first PR

Job
February 13, 2020

Submitting your first PR

I gave a workshop for the WooCommerce Happiness Engineers on submitting pull requests to GitHub.

* We discussed rerminology: Fork, Clone, Branch, Commit, Pull Request, and Merge
* We went on a bug hunt in a WordPress plugin I had messed up (deliberately)
* We submitted some pull requests together

Job

February 13, 2020
Tweet

More Decks by Job

Other Decks in Technology

Transcript

  1. Submitting your first PR
    Job Thomas
    @jobtex

    View full-size slide

  2. • Most recent (dev) version
    • Fast updates / syncing
    • Testing
    • Contributing
    GitHub = ?

    View full-size slide

  3. How would you explain the following terms?
    • Fork
    • Clone
    • Branch
    • Commit
    • Pull Request
    • Merge
    Terminology

    View full-size slide

  4. master
    branch
    commit commit commit
    pull request
    merge

    View full-size slide

  5. master
    branch
    commit
    commit commit
    pull request
    merge
    master
    org:WooCommerce
    org:jobthomas
    fork

    View full-size slide

  6. master
    branch
    commit commit commit
    pull request
    merge
    org:WooCommerce
    master
    branch
    commit commit commit
    pull request
    merge
    local
    clone pull push

    View full-size slide

  7. Terminology
    Clone copy GitHub repo to local install
    Fork copy GitHub repo to personal account
    Branch split off to test new code without touching main
    Sync sync online and local
    Commit save code changes to branch
    Pull request submit code changes to plugin master
    Merge accept code changes and combine branches

    View full-size slide

  8. • Go to this repo: github.com/jobthomas/your-first-pr
    - Fork it
    - Clone it (to local wp-content/plugins)
    • Use GitHub desktop app or Terminal
    • Activate on local install
    Branch and Clone

    View full-size slide

  9. To fork or the branch?

    View full-size slide

  10. Find and Submit Issues
    There are 6 bugs in the code.
    Find them!

    View full-size slide

  11. File: wc-minimum-order-amount.php
    1. Line 37: alert("SHOW ME THE MONEY!”); could be malicious
    code
    2. Line 42: color: white; makes amount you add in settings not readable
    3. Line 61: your order must be at least % is missing an “s” after the percentage
    sign
    4. Line 73: h_wc_minimum_order_amount function is missing an “s” (should be
    hs_)
    5. Line 83: total > $minimum will only show if the order is higher than the minimum,
    it should be “<” instead
    File: readm.txt
    6. File name should be readme.txt
    Extra points
    7. You’re likely testing this with a more recent version of WooCommerce and
    WordPress than is declared in the readme file. You can update that.
    8. Update the version number of the plugin and the changelog
    Find and Submit Issues

    View full-size slide

  12. • Self-assign issue
    • Branch 

    (give relevant name, e.g. /fix-2 where #2 is the
    bug report)
    • Edit code
    • Save changes
    Branch and Edit

    View full-size slide

  13. • Commit changes
    - Commit regularly
    - For small edits
    • Pull request
    - Into jobthomas/your-first-pr/tree/master
    - Extra points: add a gif in the PR description
    Commit and Pull

    View full-size slide

  14. Compiling
    • Fork WooCommerce
    • Clone it to your local install
    • Do same for our top extensions

    View full-size slide

  15. And now for real

    View full-size slide

  16. And now for real
    • Find open issue on WooCommerce
    - Easy to fix
    - Within your skills set
    - Tip: go to: https://github.com/issues
    - Delete author:your-username
    - Look for: label:"[Type] Good First Change"
    • Fork and clone (or if other plugin: clone and branch)
    • Branch and edit
    • Commit and submit PR

    View full-size slide

  17. Thanks!
    Job Thomas
    @jobtex

    View full-size slide