Skip to content

Commit

Permalink
fix not commiting
Browse files Browse the repository at this point in the history
  • Loading branch information
karolzak committed Sep 7, 2020
1 parent 938655d commit 2520256
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions pre_commit_nb/base64_to_image_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def process_nb(
print("Processing %s" % filename)
with open(filename, 'r') as file:
data = " ".join(file.readlines())
org_data = data.copy()
matches = re.findall(
r"\"image/(?:gif|png|jpeg|bmp|webp)\": \".*[a-zA-Z0-9+/=]\"",
data)
Expand Down Expand Up @@ -123,15 +124,15 @@ def process_nb(
base64_string, full_path
)
url_path = "./" + image_path

new_files += " " + full_path
new_files += " " + full_path

data = data.replace(match, create_nb_cell_output(url_path))

if len(new_files) > 0:
if org_data != data:
with open(filename, 'w') as file:
file.write(data)
new_files += " " + filename
new_files = new_files.strip()

if add_changes_to_staging:
print("'--add_changes_to_staging' flag set to 'True' - added new and changed files to staging.")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="pre_commit_nb",
version="0.2.1a2",
version="0.2.1a3",
description="Set of git pre-commit hooks for Jupyter Notebooks compatible with https://pre-commit.com/ framework",
long_description=long_description,
long_description_content_type="text/markdown", # This is important!
Expand Down

0 comments on commit 2520256

Please sign in to comment.