Skip to content

Commit

Permalink
Merge pull request #6 from oda-hub/gitignore-list-files
Browse files Browse the repository at this point in the history
Gitignore list files
  • Loading branch information
burnout87 authored Nov 14, 2023
2 parents ab841b1 + 034043d commit 77cdb5e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.3
0.0.4
3 changes: 1 addition & 2 deletions renkuaqsannotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def _ignore_nb2workflow():

logging.debug("Ignoring nb2workflow automatically generated folder and files")

gitignore_file("**.nb2workflow**")
gitignore_file("function.xml")
gitignore_file("**.nb2workflow**", "function.xml")


def _check_renku_version():
Expand Down
13 changes: 9 additions & 4 deletions renkuaqsannotation/io_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
from git import Repo


def gitignore_file(file_name):
def gitignore_file(*args):
if os.path.exists('.gitignore'):
with open('.gitignore') as gitignore_file_lines:
lines = gitignore_file_lines.readlines()
if file_name + "\n" not in lines:
lines.append(file_name + "\n")
lines_to_add = []
for file_name in args:
if file_name + "\n" not in lines:
lines.append(file_name + "\n")
lines_to_add.append(file_name)

if len(lines_to_add) > 0:
commit_msg = ", ".join(lines_to_add) + " files added to the .gitignore file"
with open(".gitignore", "w") as gitignore_file_write:
gitignore_file_write.writelines(lines)
commit_msg = f"{file_name} added to the .gitignore file"
repo = Repo('.')
repo.index.add(".gitignore")
repo.index.commit(commit_msg)

0 comments on commit 77cdb5e

Please sign in to comment.