|
| 1 | +# Contributing to Unix Programming and Regular Expressions Workshop |
| 2 | + |
| 3 | +Contributions to this workshop may come in many forms. Some contribute code changes, |
| 4 | +others contribute docs. |
| 5 | + |
| 6 | +No contribution is too small and all contributions are valued. |
| 7 | + |
| 8 | +This guide details the basic steps for getting started contributing to the unix workshop GitHub Repository and describes what to expect throughout each step of the process. |
| 9 | + |
| 10 | +## Submitting a Pull Request |
| 11 | + |
| 12 | +#### Setting up your local environment |
| 13 | + |
| 14 | +To get started, you will need to have `git` installed locally. Depending on |
| 15 | +your operating system, there are also a number of other dependencies required. |
| 16 | + |
| 17 | +Once you have `git` and are sure you have all of the necessary dependencies, |
| 18 | +it's time to create a fork. |
| 19 | + |
| 20 | +Before getting started, it is recommended to configure `git` so that it knows |
| 21 | +who you are: |
| 22 | + |
| 23 | +```text |
| 24 | +$ git config --global user.name "John Rambo" |
| 25 | +$ git config --global user.email "[email protected]" |
| 26 | +``` |
| 27 | +Please make sure this local email is also added to your |
| 28 | +[GitHub email list](https://github.com/settings/emails) so that your commits |
| 29 | +will be properly associated with your account and you will be promoted |
| 30 | +to Contributor once your first commit is landed. |
| 31 | + |
| 32 | +#### Step 1: Fork |
| 33 | + |
| 34 | +Fork the project [on GitHub](https://github.com/jbelmont/unix-programming-and-regular-expressions-workshop) and clone your fork locally. |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +When the fork is complete you will see the following screen |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +```text |
| 43 | +$ git clone [email protected]:jbelmont/unix-programming-and-regular-expressions-workshop.git |
| 44 | +$ cd unix-programming-and-regular-expressions-workshop |
| 45 | +$ git remote add upstream https://github.com/jbelmont/unix-programming-and-regular-expressions-workshop.git |
| 46 | +$ git fetch upstream |
| 47 | +``` |
| 48 | + |
| 49 | +#### Step 2: Branch |
| 50 | + |
| 51 | +As a best practice to keep your development environment as organized as |
| 52 | +possible, create local branches to work within. These should also be created |
| 53 | +directly off of the `master` branch. |
| 54 | + |
| 55 | +```text |
| 56 | +$ git checkout -b my-branch -t upstream/master |
| 57 | +``` |
| 58 | + |
| 59 | +#### The Process of Making Changes |
| 60 | + |
| 61 | +###### Editing Files |
| 62 | + |
| 63 | +This workshop has markdown files in the *docs* folder. |
| 64 | + |
| 65 | +If you want to edit any doc files for the repository please do so in *docs* folder |
| 66 | + |
| 67 | +For example if you wanted to fix errors in the `docs/history-substitution.md` then you would make document changes inside there. |
| 68 | + |
| 69 | +###### Adding Files |
| 70 | + |
| 71 | +The workshop has a corresponding Gitbook that is built using [Gitbook](https://toolchain.gitbook.com/) |
| 72 | + |
| 73 | +If you add a *markdown file* in the _docs_ folder then you will need to update the *SUMMARY.md* |
| 74 | + |
| 75 | +Contents of the *SUMMARY.md* |
| 76 | + |
| 77 | +```markdown |
| 78 | +## Unix Programming and Regular Expressions Workshop |
| 79 | + |
| 80 | +* [Workshop Introduction](/README.md) |
| 81 | +* [Basics of Shell Programming](docs/basics-of-shell-programming.md) |
| 82 | +* [Introduction to Text Processing](docs/introduction-to-text-processing.md) |
| 83 | +* [Text Searching](docs/text-searching.md) |
| 84 | +* [Text Substitution](docs/text-substitution.md) |
| 85 | +* [Filename expansions and globbing](docs/filename-expansions-and-globbing.md) |
| 86 | +* [Working with Fields](docs/working-with-fields.md) |
| 87 | +* [Text Sorting](docs/text-sorting.md) |
| 88 | +* [Arithmetic Operations and variables](docs/arithmetic-operations-and-variables.md) |
| 89 | +* [Decision Making and Exit Status](docs/decision-making-and-exit-status.md) |
| 90 | +* [Looping](docs/looping.md) |
| 91 | +* [Input and Output](docs/input-and-output.md) |
| 92 | +* [Command Process Substitution](docs/command-process-substitution.md) |
| 93 | +* [History Substitution](docs/history-substitution.md) |
| 94 | +* [Evaluation Order](docs/evaluation-order.md) |
| 95 | +* [Subshells](docs/subshells.md) |
| 96 | +* [Shell Functions](docs/shell-functions.md) |
| 97 | +* [Signal Handling](docs/signal-handling.md) |
| 98 | +* [Working with Files](docs/working-with-files.md) |
| 99 | +* [Building Command line applications](docs/building-command-line-applications.md) |
| 100 | +``` |
| 101 | + |
| 102 | +When you add a file to the docs folder you will need to add the entry into the file above and the logical order you think it would go into. The easiest way to do to that is to copy one of the lines and edit Name and path. |
| 103 | + |
| 104 | +Don't worry about generating the *Gitbook* once you have edited the docs file or you have added a new docs file and you have submitted your Pull Request and it is merged into master, I will do the following on my part. |
| 105 | + |
| 106 | +My steps that you don't have to worry about: |
| 107 | + |
| 108 | +1. Merge your Pull Request |
| 109 | +2. Run `git pull` in my local branch |
| 110 | +3. If you added a new file I will run the following script to update *Gitbook* Site |
| 111 | + 1. `npm run docs:publish` |
| 112 | + |
| 113 | +*package.json file*: |
| 114 | + |
| 115 | +```json |
| 116 | +{ |
| 117 | + "name": "unix-programming-and-regular-expressions-workshop", |
| 118 | + "version": "1.0.0", |
| 119 | + "description": "A workshop on Unix Programming Principles using tools such as grep, sed, awk, shell programming and regular expressions", |
| 120 | + "main": "index.js", |
| 121 | + "scripts": { |
| 122 | + "docs:prepare": "gitbook install", |
| 123 | + "docs:build": "npm run docs:prepare && rm -rf _book && gitbook build", |
| 124 | + "docs:watch": "npm run docs:prepare && gitbook serve", |
| 125 | + "docs:publish": "npm run docs:build && cd _book && git init && git commit --allow-empty -m 'Update docs' && git checkout -b gh-pages && touch .nojekyll && git add . && git commit -am 'Update docs' && git push [email protected]:jbelmont/unix-programming-and-regular-expressions-workshop.git gh-pages --force" |
| 126 | + }, |
| 127 | + "repository": { |
| 128 | + "type": "git", |
| 129 | + "url": "git+https://github.com/jbelmont/unix-programming-and-regular-expressions-workshop.git" |
| 130 | + }, |
| 131 | + "keywords": [], |
| 132 | + "author": "Jean-Marcel Belmont <[email protected]>", |
| 133 | + "license": "MIT", |
| 134 | + "bugs": { |
| 135 | + "url": "https://github.com/jbelmont/unix-programming-and-regular-expressions-workshop/issues" |
| 136 | + }, |
| 137 | + "homepage": "https://github.com/jbelmont/unix-programming-and-regular-expressions-workshop#readme", |
| 138 | + "devDependencies": { |
| 139 | + "gitbook": "^3.2.3", |
| 140 | + "gitbook-cli": "^2.3.2" |
| 141 | + } |
| 142 | +} |
| 143 | +``` |
| 144 | + |
| 145 | +You won't be able to run `npm run docs:publish` unless I give you admin rights to the repo but essentially I force push changes to github pages and the static website gets regenerated. |
| 146 | + |
| 147 | +Notice that there is a script called **docs:publish* in the *scripts* section of *package.json* |
| 148 | + |
| 149 | +##### Commit message guidelines |
| 150 | + |
| 151 | +A good commit message should describe what changed and why. |
| 152 | + |
| 153 | +1. The first line should: |
| 154 | + - contain a short description of the change |
| 155 | + - be 50 characters or less |
| 156 | + - be entirely in lowercase with the exception of proper nouns, acronyms, and |
| 157 | + the words that refer to code, like function/variable names |
| 158 | + |
| 159 | +2. Keep the second line blank. |
| 160 | +3. Wrap all other lines at 72 columns. |
| 161 | + |
| 162 | +4. If your patch fixes an open issue, you can add a reference to it at the end |
| 163 | +of the log. Use the `Fixes:` prefix and the full issue URL. |
| 164 | + |
| 165 | + Examples: |
| 166 | + - `Fixes: https://github.com/jbelmont/unix-programming-and-regular-expressions-workshop/issues/10` |
| 167 | + |
| 168 | +Sample complete commit message: |
| 169 | + |
| 170 | +```txt |
| 171 | +Body of commit message is a few lines of text, explaining things |
| 172 | +in more detail, possibly giving some background about the issue |
| 173 | +being fixed, etc. |
| 174 | +
|
| 175 | +The body of the commit message can be several paragraphs, and |
| 176 | +please do proper word-wrap and keep columns shorter than about |
| 177 | +72 characters or so. That way, `git log` will show things |
| 178 | +nicely even when it is indented. |
| 179 | +
|
| 180 | +Fixes: https://github.com/jbelmont/unix-programming-and-regular-expressions-workshop/issues/10 |
| 181 | +``` |
| 182 | + |
| 183 | +#### Step 5: Rebase |
| 184 | + |
| 185 | +As a best practice, once you have committed your changes, it is a good idea |
| 186 | +to use `git rebase` (not `git merge`) to synchronize your work with the main |
| 187 | +repository. |
| 188 | + |
| 189 | +```text |
| 190 | +$ git fetch upstream |
| 191 | +$ git rebase upstream/master |
| 192 | +``` |
| 193 | + |
| 194 | +This ensures that your working branch has the latest changes from `nodejs/node` |
| 195 | +master. |
| 196 | + |
| 197 | +#### Step 7: Push |
| 198 | + |
| 199 | +Once you are sure your commits are ready to go, begin the process of opening a Pull Request by pushing your working branch to your fork on GitHub. |
| 200 | + |
| 201 | +```text |
| 202 | +$ git push origin my-branch |
| 203 | +``` |
| 204 | + |
| 205 | +#### Step 8: Opening the Pull Request |
| 206 | + |
| 207 | +From within GitHub, opening a new Pull Request will present you with a template |
| 208 | +that should be filled out: |
| 209 | + |
| 210 | +```markdown |
| 211 | +<!-- |
| 212 | +Thank you for your pull request. Please provide a description above and review |
| 213 | +the requirements below. |
| 214 | + |
| 215 | +Contributors guide: https://github.com/jbelmont/blob/master/CONTRIBUTING.md |
| 216 | +--> |
| 217 | + |
| 218 | +##### Checklist |
| 219 | +<!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> |
| 220 | + |
| 221 | +- [ ] documentation is changed or added |
| 222 | +- [ ] script changes are made |
| 223 | +``` |
| 224 | + |
| 225 | +Please try to do your best at filling out the details, but feel free to skip |
| 226 | +parts if you're not sure what to put. |
| 227 | + |
| 228 | +Once opened, Pull Requests are usually reviewed within a few days. |
0 commit comments