Skip to content

Commit

Permalink
Merge pull request #43 from usefulness/use_fork
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski authored Feb 6, 2022
2 parents 19f8c68 + 1068752 commit 0a89396
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ The work
##### Parameters
`old-file-path` - Path to reference file the diff should be generated for
`new-file-path` - Path to current file the diff should be generated for
`lib-version` _(Optional)_ - Overrides [Diffuse](https://github.com/JakeWharton/diffuse) dependency version
`lib-version` _(Optional)_ - Overrides [Diffuse](https://github.com/JakeWharton/diffuse) dependency version
`fork-version` _(Optional)_ - Uses [Diffuse](https://github.com/usefulness/diffuse) fork with a fiven version

### Sample: Create Pull Request comment

Expand Down
12 changes: 8 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ inputs:
description: 'new mapping file produced by R8 or ProGuard'
required: false
lib-version:
description: 'diffuse tool version'
required: true
default: '0.1.0'
description: 'JakeWharton/diffuse tool version'
required: false
fork-version:
description: 'usefulness/diffuse fork version'
required: false
default: '0.2.0'
debug:
description: 'if true, shows additional debug information'
required: false
default: false
default: 'false'
outputs:
diff-raw:
description: "Diffuse full output"
Expand Down Expand Up @@ -91,6 +94,7 @@ runs:
INPUT_OLD_MAPPING_FILE: ${{ inputs.old-mapping-path }}
INPUT_NEW_MAPPING_FILE: ${{ inputs.new-mapping-path }}
INPUT_VERSION: ${{ inputs.lib-version }}
INPUT_FORK_VERSION: ${{ inputs.fork-version }}
INPUT_DEBUG: ${{ inputs.debug }}
run: python3 ${{ github.action_path }}/entrypoint.py
shell: bash
22 changes: 16 additions & 6 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,28 @@
from itertools import zip_longest


def find_tool_url():
lib_version = os.getenv("INPUT_VERSION", "").strip()
if lib_version:
return "https://github.com/JakeWharton/diffuse/releases/download/{0}/diffuse-{0}-binary.jar" \
.format(lib_version)
else:
return "https://github.com/usefulness/diffuse/releases/download/{0}/diffuse-{0}-binary.jar" \
.format(os.getenv("INPUT_FORK_VERSION"))


def is_debug():
return os.getenv("INPUT_DEBUG", False)


def github_output(message: str):
def github_output(message):
return message.replace("%", "%25") \
.replace("\n", "%0A") \
.replace("\r", "%0D") \
.replace('\x00', '')


def section(_title: str, _content: str):
def section(_title, _content):
return f"""
<details>
<summary>{_title}</summary>
Expand All @@ -29,7 +39,7 @@ def section(_title: str, _content: str):
"""


def header(_content: str):
def header(_content):
return f"""
\\`\\`\\`
{_content}
Expand All @@ -56,8 +66,7 @@ def sizeof_fmt(num, suffix='B', sign=False):
return "%.1f%s%s" % (num, 'Yi', suffix)


url = "https://github.com/JakeWharton/diffuse/releases/download/{0}/diffuse-{0}-binary.jar" \
.format(os.getenv("INPUT_VERSION"))
url = find_tool_url()
downloadArgs = ""
if not is_debug():
downloadArgs += "-q"
Expand Down Expand Up @@ -156,4 +165,5 @@ def sizeof_fmt(num, suffix='B', sign=False):
os.system(f"echo \"::set-output name=diff-gh-comment::{github_output(github_comment)}\"")
os.system(f"echo \"::set-output name=diff-gh-comment-all-collapsed::{github_output(github_comment_all_collapsed)}\"")
os.system(f"echo \"::set-output name=diff-gh-comment-no-dex::{github_output(github_comment_no_dex)}\"")
os.system(f"echo \"::set-output name=diff-gh-comment-no-dex-all-collapsed::{github_output(github_comment_no_dex_all_collapsed)}\"")
os.system(
f"echo \"::set-output name=diff-gh-comment-no-dex-all-collapsed::{github_output(github_comment_no_dex_all_collapsed)}\"")

0 comments on commit 0a89396

Please sign in to comment.