Let's create the same problem again, but this time use some of the tools on GitHub to solve the problem - let's introduce issues and Pull Requests.
Study this code You've already seen most of it before - what do you think is happening?
Run it!
git co master
git pull origin master
cd $(git root)
mkdir pr-lab
POEM=$(git root)/pr-lab/eeny-meeny-miny-moe.txt
cat <<ENDOFPOEM > $POEM
Eeny, meeny, miny, moe,
Catch a tiger by the toe.
If he hollers, let him go,
Eeny, meeny, miny, moe.
My mother told me to pick
the very best one and you - are - it!"
ENDOFPOEM
git add $POEM && git commit -m "I published a poem"
git tag v01.0.0
git pull origin master && git push --tags origin master
Always work on an issue
It's an integrated part of the underlying concepts in both Scrum boards and Kanban boards that work only happens for a reason You could say that any change to the code base must be related to a card that is create in forehand. There's always a pupose!
So consequnently - If we want to improive the poem, we first need an issue (task, user story) that instructs us to do so.
So you should go to the webpage on GitHub (gh browse) for this repo and create new issue - assign it to yourself:
title: "Fix the Eeeny Meeny poem"
body: "No rules, just improve whatever you like"
assignee: "@me"
label: "bug"
Could have created an issue from the command line?
---
Of course:
```
gh issue create \
--title "Fix the Eeeny Meeny poem" \
--body "No rules, just improve whatever you like" \
--assignee "@me" \
--label "bug"
```
- The entire command is one _statement_ but for readability it spawns multiple lines using `\` as line-ending on lines that are _continued_.
It returns the URL to the newly created issue
---
Now create a branch which is specifically related to this particular issue.
On the icon panel to the left in your VC Code click the GitHub icon. In the lover panel you see the GitHub issues - since you assigned the issue to your selv it should show up - something like:
The Arrow icon will create a new branch, related to this issue.
The globe will take you to the issue on GitHub in the example (issue 39) the same as gh browse 39.
[ ] Create a branch on your issue.
NOTE: You terminal might show you, that you are still on master but just hit enter once to get the new status in your prompt.
Could have create a branch from an issue from the command line?
---
Of course:
```shell
# Create a branch off issue no. 39
gh issue develop --checkout 39
```
Hold on tight I'll show you how we could even have created and the issue and the branch - in one go:
```
gh issue develop --checkout $(gh issue create \
--title "Fix the Eeeny Meeny poem" \
--body "No rules, just improve whatever you like" \
--assignee "@me" \
--label "bug" \
| grep -oP "https:.*\/\K(\d+)$")
```
Quite a few elements makes this command semi-advanced:
The `gh issue develop` command needs to know the issue number of the one just created - we will get that by parsing the output of the `gh issue create` command.
The entire gh issue create command is wrapped up in Command Substitution$(...)which is passed to the gh issue develop command.
The command that created the issue gh issue create is piped | to another command called grep.
grep runs a perl-style -P regular expression which is instructed only to return the actual match -o.
The regular expression https:.*\/\K(\d+)$ is passed as a string, so it must escape the special chars: \/ and \.
The regular expression even shortens the match with a don't look back option \K. Effectively only returning the tailing $ integer from the line which contains https:.
Mind blowing!
Fix the poem
[ ] Open the new poem (./pr-lab/eeny-meeny-miny-moe.txt) and make some fixes.
[ ] git add your changes
[ ] git commit your changes
[ ] git push your change
HEY - the push wasn't straight forward - you probably got something like:
fatal: The current branch <USER>/issue11 has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin republicdomain/issue11
Calm! Theres nothing in git you can't automate - so of course there is a solution to this issue too. As you might have guessed the solution is a setting in you gitconfig file.
Let's create the same problem again, but this time use some of the tools on GitHub to solve the problem - let's introduce issues and Pull Requests.
Study this code You've already seen most of it before - what do you think is happening?
Run it!
Always work on an issue
It's an integrated part of the underlying concepts in both Scrum boards and Kanban boards that work only happens for a reason You could say that any change to the code base must be related to a card that is create in forehand. There's always a pupose!
So consequnently - If we want to improive the poem, we first need an issue (task, user story) that instructs us to do so.
So you should go to the webpage on GitHub (
gh browse
) for this repo and create new issue - assign it to yourself:Could have created an issue from the command line?
--- Of course: ``` gh issue create \ --title "Fix the Eeeny Meeny poem" \ --body "No rules, just improve whatever you like" \ --assignee "@me" \ --label "bug" ``` - The entire command is one _statement_ but for readability it spawns multiple lines using `\` as line-ending on lines that are _continued_. It returns the URL to the newly created issue ---Now create a branch which is specifically related to this particular issue.
On the icon panel to the left in your VC Code click the GitHub icon. In the lover panel you see the GitHub issues - since you assigned the issue to your selv it should show up - something like:
The Arrow icon will create a new branch, related to this issue.
The globe will take you to the issue on GitHub in the example (issue 39) the same as
gh browse 39
.[ ] Create a branch on your issue.
NOTE: You terminal might show you, that you are still on
master
but just hit enter once to get the new status in your prompt.Could have create a branch from an issue from the command line?
--- Of course: ```shell # Create a branch off issue no. 39 gh issue develop --checkout 39 ``` Hold on tight I'll show you how we could even have created and the issue and the branch - in one go: ``` gh issue develop --checkout $(gh issue create \ --title "Fix the Eeeny Meeny poem" \ --body "No rules, just improve whatever you like" \ --assignee "@me" \ --label "bug" \ | grep -oP "https:.*\/\K(\d+)$") ``` Quite a few elements makes this command semi-advanced: The `gh issue develop` command needs to know the issue number of the one just created - we will get that by parsing the output of the `gh issue create` command.The entire
gh issue create
command is wrapped up in Command Substitution$(...)
which is passed to thegh issue develop
command.The command that created the issue
gh issue create
is piped|
to another command calledgrep
.grep
runs a perl-style-P
regular expression which is instructed only to return the actual match-o
.The regular expression
https:.*\/\K(\d+)$
is passed as a string, so it must escape the special chars:\/
and\
.The regular expression even shortens the match with a don't look back option
\K
. Effectively only returning the tailing$
integer from the line which containshttps:
.Mind blowing!
Fix the poem
[ ] Open the new poem (
./pr-lab/eeny-meeny-miny-moe.txt
) and make some fixes.[ ]
git add
your changes[ ]
git commit
your changes[ ]
git push your change
HEY - the
push
wasn't straight forward - you probably got something like:Calm! Theres nothing in git you can't automate - so of course there is a solution to this issue too. As you might have guessed the solution is a setting in you gitconfig file.
push.default
-- read all about it!The pattern setting you are looking for is probably
current
.[ ] Try this:
[ ] Go to GitHub and find the commit you just pushed - create a pull request from it!
NOTE: Did you read the output from the
git push
command - I has a nice surprise!Could have created a PR from the command line?
--- Of course: ...See if you can [figure it out](https://cli.github.com/manual/) ---