Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitignore list files #6

Merged
merged 9 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)