Skip to content

Instantly share code, notes, and snippets.

@conroywhitney
Forked from lukebergen/prepare-commit-msg
Last active December 22, 2021 20:12
Show Gist options
  • Save conroywhitney/c8a658026a1290e06ae65297afdc8f59 to your computer and use it in GitHub Desktop.
Save conroywhitney/c8a658026a1290e06ae65297afdc8f59 to your computer and use it in GitHub Desktop.

Revisions

  1. conroywhitney revised this gist Dec 22, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ non_ammend = `head -n1 #{file}` == "\n"

    if id.to_i.to_s == id && non_ammend
    original = File.read(file)
    text = "#{id}\n\n[#{id}](https://app.shortcut.com/reviewed/story/#{id})\n#{original}"
    text = "\n\n[#{id}](https://app.shortcut.com/reviewed/story/#{id})\n#{original}"
    File.open(file, "w+") do |f|
    f.write(text)
    end
  2. conroywhitney revised this gist Dec 22, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -5,13 +5,13 @@
    file = ARGV[0]
    branch_path = `git symbolic-ref -q HEAD`.split("\n")[0] # Somthing like refs/heads/myBranchName
    branch_name = branch_path.split("/").last
    chid = branch_name.split("-").last.gsub(/ch/i, '')
    id = branch_name.split("-").last

    non_ammend = `head -n1 #{file}` == "\n"

    if chid.to_i.to_s == chid && non_ammend
    if id.to_i.to_s == id && non_ammend
    original = File.read(file)
    text = "CH#{chid}\n\n[CH#{chid}](https://app.clubhouse.io/reviewed/story/#{chid})\n#{original}"
    text = "#{id}\n\n[#{id}](https://app.shortcut.com/reviewed/story/#{id})\n#{original}"
    File.open(file, "w+") do |f|
    f.write(text)
    end
  3. @lukebergen lukebergen revised this gist May 3, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ non_ammend = `head -n1 #{file}` == "\n"

    if chid.to_i.to_s == chid && non_ammend
    original = File.read(file)
    text = "#{chid}\n\n[#{chid}](https://app.clubhouse.io/reviewed/story/#{chid})\n#{original}"
    text = "CH#{chid}\n\n[CH#{chid}](https://app.clubhouse.io/reviewed/story/#{chid})\n#{original}"
    File.open(file, "w+") do |f|
    f.write(text)
    end
  4. @lukebergen lukebergen revised this gist May 3, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    file = ARGV[0]
    branch_path = `git symbolic-ref -q HEAD`.split("\n")[0] # Somthing like refs/heads/myBranchName
    branch_name = branch_path.split("/").last
    chid = branch_name.split("-").last
    chid = branch_name.split("-").last.gsub(/ch/i, '')

    non_ammend = `head -n1 #{file}` == "\n"

  5. @lukebergen lukebergen created this gist May 3, 2019.
    18 changes: 18 additions & 0 deletions prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/usr/bin/env ruby

    # Automatically adds clubhouse id and link to commit messages based on branch name

    file = ARGV[0]
    branch_path = `git symbolic-ref -q HEAD`.split("\n")[0] # Somthing like refs/heads/myBranchName
    branch_name = branch_path.split("/").last
    chid = branch_name.split("-").last

    non_ammend = `head -n1 #{file}` == "\n"

    if chid.to_i.to_s == chid && non_ammend
    original = File.read(file)
    text = "#{chid}\n\n[#{chid}](https://app.clubhouse.io/reviewed/story/#{chid})\n#{original}"
    File.open(file, "w+") do |f|
    f.write(text)
    end
    end