Skip to content

Instantly share code, notes, and snippets.

@michaelsteuer
Forked from james2doyle/bb-compare.fish
Created December 30, 2024 04:38
Show Gist options
  • Save michaelsteuer/3cafb69efee3a5416bafb86a25f0171e to your computer and use it in GitHub Desktop.
Save michaelsteuer/3cafb69efee3a5416bafb86a25f0171e to your computer and use it in GitHub Desktop.
Create a bitbucket URL to compare 2 commits
# Based on: https://gist.github.com/danlherman/8a32fa05c2cf6018ed10
# creates a URL to compare 2 commits
# takes 2 commit hashes (future past), or 1 hash and it will compare to the current commit
function bb-compare
set repo_name (git remote show origin | grep "Fetch URL:" | awk -F: '{print $3}')
switch (count $argv);
case 1
set commit_one (git log --pretty=format:"%h" | head -n 1)
set commit_two $argv[1]
echo "Comparing latest commit ($commit_one) and $commit_two"
case 2;
set commit_one $argv[1]
set commit_two $argv[2]
echo "Comparing $commit_one and $commit_two"
end
set start_url "https://bitbucket.org/$repo_name/branches/compare/$commit_one..$commit_two#diff"
echo $start_url
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment