mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Compare commits
2 Commits
e2eb31a4a9
...
d1f41884ce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1f41884ce | ||
|
|
91149fe7cc |
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1683 TILs and counting..._
|
||||
_1685 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
|
||||
@@ -409,6 +409,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Show File Diffs When Viewing Git Log](git/show-file-diffs-when-viewing-git-log.md)
|
||||
- [Show List Of Most Recently Committed Branches](git/show-list-of-most-recently-committed-branches.md)
|
||||
- [Show Only Commits That Touch Specific Lines](git/show-only-commits-that-touch-specific-lines.md)
|
||||
- [Show Summary Stats For Current Branch](git/show-summary-stats-for-current-branch.md)
|
||||
- [Show The diffstat Summary Of A Commit](git/show-the-diffstat-summary-of-a-commit.md)
|
||||
- [Show The Good And The Bad With Git Bisect](git/show-the-good-and-the-bad-with-git-bisect.md)
|
||||
- [Show What Is In A Stash](git/show-what-is-in-a-stash.md)
|
||||
@@ -1435,6 +1436,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Scripting With RVM](ruby/scripting-with-rvm.md)
|
||||
- [Scroll To Top Of Page With Capybara](ruby/scroll-to-top-of-page-with-capybara.md)
|
||||
- [Search For Gem Versions Available To Install](ruby/search-for-gem-versions-available-to-install.md)
|
||||
- [Set Default Tasks For Rake To Run](ruby/set-default-tasks-for-rake-to-run.md)
|
||||
- [Set RVM Default Ruby](ruby/set-rvm-default-ruby.md)
|
||||
- [Shift The Month On A Date Object](ruby/shift-the-month-on-a-date-object.md)
|
||||
- [Show Public Methods With Pry](ruby/show-public-methods-with-pry.md)
|
||||
|
||||
26
git/show-summary-stats-for-current-branch.md
Normal file
26
git/show-summary-stats-for-current-branch.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Show Summary Stats For Current Branch
|
||||
|
||||
When I push a branch up to GitHub as a PR, there is a part of the UI that shows
|
||||
you how many lines you've added and removed for this branch. It bases that off
|
||||
the target branch which is typically your `main` branch.
|
||||
|
||||
The `git diff` command can provide those same stats right in the terminal. The
|
||||
key is to specify the `--shortstat` flag which tells `git` to exclude other diff
|
||||
output and only show:
|
||||
|
||||
- Number of files changed
|
||||
- Number of insertions
|
||||
- Number of deletions
|
||||
|
||||
Here is the summary stats for a branch I'm working on:
|
||||
|
||||
```bash
|
||||
❯ git diff --shortstat main
|
||||
8 files changed, 773 insertions(+), 25 deletions(-)
|
||||
```
|
||||
|
||||
We have to be on our feature branch and then we point to the branch (or whatever
|
||||
ref) we want to diff against. Since I want to know how my feature branch
|
||||
compares to `main`, I specify that.
|
||||
|
||||
See `man git-diff` for more details.
|
||||
32
ruby/set-default-tasks-for-rake-to-run.md
Normal file
32
ruby/set-default-tasks-for-rake-to-run.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# Set Default Tasks For Rake To Run
|
||||
|
||||
Let's say our Ruby codebase has a `test` rake task and a `test:system` rake
|
||||
task. One runs our unit tests and the other runs our system (headless
|
||||
browser-based) tests. They aren't necessary defined in our `Rakefile`. In fact,
|
||||
that's how it is in a Rails codebase where these are defined by Rails itself.
|
||||
|
||||
We want the default action when [`rake`](https://ruby.github.io/rake/) is
|
||||
invoked by itself to be to run both of those test tasks.
|
||||
|
||||
This can be accomplished by specifying a `default` task and specifying both of
|
||||
those tasks as prerequisites.
|
||||
|
||||
```ruby
|
||||
task default: ["test", "test:system"]
|
||||
```
|
||||
|
||||
The `default` task itself does nothing. When we invoke it though, it has to run
|
||||
our prerequisites. So running `rake` results in `test` and then `test:system`
|
||||
getting run.
|
||||
|
||||
If I have something like
|
||||
[`unicornleap`](https://github.com/dkarter/dotfiles/blob/b5aae6a9edd5766f0cc9100235b0955a9d53aa85/installer/mac-setup.sh#L47-L74)
|
||||
or
|
||||
[`confetti`](https://manual.raycast.com/deeplinks#block-702a9613bc82440d853492f553876a20),
|
||||
then I can have one of those run in the event that all the prerequisites pass.
|
||||
|
||||
```ruby
|
||||
task default: ["test", "test:system"] do
|
||||
system("unicornleap") if system("which unicornleap > /dev/null 2>&1")
|
||||
end
|
||||
```
|
||||
Reference in New Issue
Block a user