Module: PWN::Plugins::Git
- Defined in:
- lib/pwn/plugins/git.rb
Overview
Used primarily in the past to clone local repos and generate an html diff to be sent via email (deprecated). In the future this plugin may be used to expand upon capabilities required w/ Git.
Constant Summary collapse
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
Jacob Hoopes <[email protected]>.
-
.dump_all_repo_branches(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::Git.dump_all_repo_branches( git_url: ‘required git repo url’ ).
-
.gen_html_diff(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::Git.gen_html_diff( repo: ‘required git repo name’, branch: ‘required git repo branch (e.g. master, develop, etc)’, since: ‘optional date, otherwise default to last pull’ ).
-
.get_author(opts = {}) ⇒ Object
- Supported Method Parameters
-
get_author( repo_root: dir_path, from_line: line_no, to_line:line_no, target_file: entry, entry_beautified: entry_beautified ).
-
.help ⇒ Object
Display Usage for this Module.
Class Method Details
.authors ⇒ Object
- Author(s)
-
Jacob Hoopes <[email protected]>
133 134 135 136 137 |
# File 'lib/pwn/plugins/git.rb', line 133 public_class_method def self. "AUTHOR(S): Jacob Hoopes <[email protected]> " end |
.dump_all_repo_branches(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::Git.dump_all_repo_branches(
git_url: 'required git repo url'
)
76 77 78 79 80 81 |
# File 'lib/pwn/plugins/git.rb', line 76 public_class_method def self.dump_all_repo_branches(opts = {}) git_url = opts[:git_url].to_s.scrub `git ls-remote #{git_url}`.to_s.scrub rescue StandardError => e raise e end |
.gen_html_diff(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::Git.gen_html_diff(
repo: 'required git repo name', branch: 'required git repo branch (e.g. master, develop, etc)', since: 'optional date, otherwise default to last pull'
)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pwn/plugins/git.rb', line 19 public_class_method def self.gen_html_diff(opts = {}) git_repo_name = opts[:repo].to_s git_repo_branch = opts[:branch].to_s since_date = opts[:since] git_pull_output = '<div style="background-color:#CCCCCC; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">' if since_date git_pull_output << "<h3>#{git_repo_name}->#{git_repo_branch} Diff Summary Since #{since_date}</h3>" git_entity = `git log --since #{since_date} --stat-width=65535 --graph`.to_s.scrub else git_pull_output << "<h3>#{git_repo_name}->#{git_repo_branch} Diff Summary Since Last Pull</h3>" git_entity = `git log ORIG_HEAD.. --stat-width=65535 --graph`.to_s.scrub end # For debugging purposes @@logger.info(git_entity) git_pull_output << git_entity.gsub("\n", '<br />') git_pull_output << '</div>' git_pull_output << '<br />' git_pull_output rescue StandardError => e raise e end |
.get_author(opts = {}) ⇒ Object
- Supported Method Parameters
-
get_author(
repo_root: dir_path, from_line: line_no, to_line:line_no, target_file: entry, entry_beautified: entry_beautified
)
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/pwn/plugins/git.rb', line 92 public_class_method def self.(opts = {}) repo_root = opts[:repo_root] from_line = opts[:from_line] to_line = opts[:to_line] target_file = opts[:target_file] entry_beautified = opts[:entry_beautified] # In order to get the original author # we need to query the original file # instead of the .JS-BEAUTIFIED file if entry_beautified target_file.gsub!(/\.JS-BEAUTIFIED$/, '') target_file_line_length = `wc -l #{target_file}`.split.first.to_i target_file_line_length = 1 if target_file_line_length < 1 # wc -l doesn't count line is \n is missing = ( repo_root: repo_root, from_line: 1, to_line: target_file_line_length, target_file: target_file ) else if from_line.to_i && to_line.to_i < 1 from_line = 1 to_line = 1 end = ( repo_root: repo_root, from_line: from_line, to_line: to_line, target_file: target_file ) end rescue StandardError => e raise e end |
.help ⇒ Object
Display Usage for this Module
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/pwn/plugins/git.rb', line 141 public_class_method def self.help puts %{USAGE: git_html_resp = #{self}.gen_html_diff( repo: 'required git repo name', branch: 'required git repo branch (e.g. master, develop, etc)', since: 'optional date, otherwise default to last pull' ) author = #{self}.get_author( repo_root: 'optional path to git repo root (defaults to ".")' from_line: 'required line number to start in range', to_line: 'required line number to stop in range', target_file: 'required file in which line range is queried' entry_beautified: 'required boolean' ) all_repo_branches = #{self}.dump_all_repo_branches( git_url: 'required git repo url' ) #{self}.authors } end |