Created
January 16, 2017 19:31
-
-
Save AlexKalinin/c061afd27d5c22ce9a142e0ad9a8b535 to your computer and use it in GitHub Desktop.
Diff only current branch to master (even if master was updated after current branch creation)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# frozen_string_literal: true | |
require 'tempfile' | |
branch = ARGV.first || 'HEAD' | |
data = `git log --no-merges --author=login.hedin@gmail.com --oneline master..#{branch}` | |
commits = data.split("\n").map { |s| s.scan(/\w+ /).first.strip } | |
patch = '' | |
commits.each do |commit| | |
commit_data = <<-SEPARATOR | |
---------------------------------------------------------------------- | |
---------------------------------------------------------------------- | |
------------------ PATCH FOR COMMIT: #{commit} ----------------------- | |
---------------------------------------------------------------------- | |
---------------------------------------------------------------------- | |
SEPARATOR | |
commit_data << `git show #{commit} --stat` | |
commit_data << `git show #{commit} --unified=20` | |
patch << commit_data | |
end | |
path = File.join Dir::Tmpname.tmpdir, Dir::Tmpname.make_tmpname('commits', '.diff') | |
File.open(path, 'w') { |f| f.write patch } | |
`atom -a #{path}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment