Skip to content

Commit

Permalink
Support for gitinfo.json
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Jan 4, 2024
1 parent a075355 commit 45ed176
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ Change Log
8.7.1
=====

* Changed scripts/publish_to_pypi.py to allow untracked gitinfo.json to exist;
this so that we can (optionally) have repos write relevant git info to this
file (via GitHub Actions) and make it accessible to the package for inspection.
* Changed scripts/publish_to_pypi.py to allow gitinfo.json to have unstaged changes;
this is so we can optionally have repos write relevant git (repo, branch, commit) info
to this file (via GitHub Actions) and make it accessible to the package for inspection.


8.7.0
Expand Down
14 changes: 7 additions & 7 deletions dcicutils/scripts/publish_to_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ def verify_git_repo() -> bool:

def verify_unstaged_changes() -> bool:
"""
If the current git repo has no unstaged changes then returns True,
otherwise prints an error message and returns False.
If the current git repo has NO unstaged changes then returns True,
otherwise prints an error message and returns False. HOWEVER, we DO
allow unstaged changes to just the file gitinfo.json if such exists; to
allow GitHub Actions to update with latest git (repo, branch, commit) info.
"""
git_diff_results, _ = execute_command("git diff")
if git_diff_results:
git_diff_results, _ = execute_command("git diff --name-only")
if git_diff_results and not (len(git_diff_results) == 1 and
os.path.basename(git_diff_results[0]) == "gitinfo.json"):
ERROR_PRINT("You have changes to this branch that you have not staged for commit.")
return False
return True
Expand Down Expand Up @@ -243,9 +246,6 @@ def get_untracked_files() -> list:
# Ignore any __pycache__ directories as they are already ignored by poetry publish.
if os.path.isdir(untracked_file) and os.path.basename(untracked_file.rstrip("/")) == "__pycache__":
continue
# Ignore gitinfo.json which may exist if the repo wants to create this via GitHub Actions.
if os.path.basename(untracked_file) == "gitinfo.json":
continue
untracked_files.append(untracked_file)
return untracked_files

Expand Down

0 comments on commit 45ed176

Please sign in to comment.