Skip to content

Commit

Permalink
grabbranch name
Browse files Browse the repository at this point in the history
  • Loading branch information
nikellepetrillo committed Dec 12, 2024
1 parent 29540b1 commit 8d6e546
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions scripts/dockstore_api/fetch_dockstore_commit.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import requests
import sys
import logging

# Configure logging to display INFO level and above messages
logging.basicConfig(
level=logging.INFO, # This will show INFO and higher levels (INFO, WARNING, ERROR, CRITICAL)
format='%(asctime)s - %(levelname)s - %(message)s'
)

def fetch_commit_id(token, repository, version_name):
# Fetch the workflow data
Expand All @@ -22,7 +15,6 @@ def fetch_commit_id(token, repository, version_name):

# Extract workflow ID and version ID
workflow_id = data.get("id")

version_id = next(
(version["id"] for version in data.get("workflowVersions", [])
if version["name"] == version_name),
Expand All @@ -43,17 +35,18 @@ def fetch_commit_id(token, repository, version_name):
if not commit_id:
raise ValueError("Commit ID could not be found.")

print(f"Dockstore Commit ID: {commit_id}")
return commit_id

if __name__ == "__main__":
if len(sys.argv) != 4:
logging.error("Usage: python fetch_dockstore_commit.py <token> <repository> <version_name>")
print("Usage: python fetch_dockstore_commit.py <token> <repository> <version_name>")
sys.exit(1)

_, token, repository, version_name = sys.argv

try:
commit_id = fetch_commit_id(token, repository, version_name)
logging.info(f"Dockstore Commit ID: {commit_id}")
print(commit_id)
except Exception as e:
logging.error(f"Error: {e}")
print(f"Error: {e}")

0 comments on commit 8d6e546

Please sign in to comment.