-
-
Notifications
You must be signed in to change notification settings - Fork 0
Avatar url #8
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
base: master
Are you sure you want to change the base?
Avatar url #8
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,24 +52,19 @@ def ensure_avatar(username: str, current_avatar_url: str) -> Path | None: | |
| dest = avatar_path(username) | ||
| meta = _load_json(META_FILE) | ||
| now = datetime.now(timezone.utc).isoformat() | ||
| cached_url = meta.get("avatar_url") | ||
| last_checked_raw = meta.get("avatar_last_checked") | ||
|
|
||
| # first run | ||
| if not dest.exists() or not last_checked_raw: | ||
| if _download_avatar(current_avatar_url, dest): | ||
| meta.update({"avatar_url": current_avatar_url, "avatar_last_checked": now}) | ||
| _save_json(META_FILE, meta) | ||
| return dest | ||
| return None | ||
|
|
||
| # within 6 hours, serve from disk | ||
| if not _is_stale(last_checked_raw, AVATAR_REFRESH): | ||
| return dest | ||
|
|
||
| # past 6 hours, re-download only if URL changed | ||
| if current_avatar_url != cached_url: | ||
| _download_avatar(current_avatar_url, dest) | ||
| # turns out GitHub avatar urls don't change so fuck this shit honestly | ||
| _download_avatar(current_avatar_url, dest) | ||
|
|
||
| meta.update({"avatar_url": current_avatar_url, "avatar_last_checked": now}) | ||
| _save_json(META_FILE, meta) | ||
|
Comment on lines
+67
to
70
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handle avatar download failure before advancing cache metadata. If Proposed fix- _download_avatar(current_avatar_url, dest)
-
- meta.update({"avatar_url": current_avatar_url, "avatar_last_checked": now})
- _save_json(META_FILE, meta)
+ if _download_avatar(current_avatar_url, dest):
+ meta.update({"avatar_url": current_avatar_url, "avatar_last_checked": now})
+ _save_json(META_FILE, meta)
+ else:
+ # Keep prior last_checked so next call retries sooner.
+ if not dest.exists():
+ return None🤖 Prompt for AI Agents
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will look into it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For softprops/action-gh-release@v2, what tag is used by default on workflow_dispatch events, and istag_namerequired to force a specific release tag?💡 Result:
For softprops/action-gh-release@v2, the tag_name input defaults to github.ref_name [1][2][3]. When running via a workflow_dispatch event, github.ref_name corresponds to the branch or tag from which the workflow was triggered, which may not be a valid release tag [1][2][4]. Because the action requires a valid Git tag to create a GitHub Release, it will fail if the default github.ref_name is not a valid tag [4]. Therefore, while tag_name is technically optional in the action's configuration schema, it is effectively required for workflow_dispatch events to ensure the release is associated with a specific, valid tag [4]. To force a specific release tag, you must explicitly provide the desired tag to the tag_name input [3][5][6].
Citations:
🏁 Script executed:
Repository: PranavU-Coder/hubfetch
Length of output: 146
🏁 Script executed:
Repository: PranavU-Coder/hubfetch
Length of output: 146
🏁 Script executed:
Repository: PranavU-Coder/hubfetch
Length of output: 1768
🌐 Web query:
softprops/action-gh-release v2 tag_name must exist as git tag workflow_dispatch default github.ref_name branch💡 Result:
The softprops/action-gh-release action (including v2) does not strictly require the tag_name to exist as a pre-existing Git tag in your repository before the action runs [1][2]. If you do not explicitly provide a tag_name, the action defaults to using github.ref_name [1][2]. When triggered by a workflow_dispatch or other events, github.ref_name will reflect the branch or tag name that triggered the workflow [1][2]. If you want to use this action to create a release based on a specific commit or branch, you can explicitly set the tag_name input [1][2]. Key considerations: 1. Tag Creation: If the tag_name provided does not exist as a Git reference, the action can still create a GitHub Release associated with the provided target_commitish (which defaults to the repository's default branch) [1][2]. 2. Workflow Triggers: When using workflow_dispatch, github.ref_name will typically be the branch from which the workflow was manually triggered. If you manually trigger the workflow on a branch, the action will use that branch name as the release tag_name unless you override it [1][2]. 3. Permissions: Ensure your job has the appropriate permissions (contents: write) to create releases, otherwise you may encounter a 403 error [3]. In summary, while the action is commonly used with Git tags (e.g., via on: push: tags:), it is flexible enough to create releases for arbitrary commit SHAs or branch names by explicitly defining the tag_name input [1][2].
Citations:
Use the
workflow_dispatchversioninput for the release tag (tag_name).github/workflows/build.ymldefinesworkflow_dispatch.inputs.version, but the “Create GitHub Release” step (softprops/action-gh-release@v2) never uses it; withouttag_name, the action usesgithub.ref_name(typically the branch name for manual dispatch), so the created release tag won’t match the operator’s chosen version.Proposed fix
- name: Create GitHub Release uses: softprops/action-gh-release@v2 with: + tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} files: artifacts/* generate_release_notes: true🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PranavU-Coder, glad you agree! When you're ready, you can apply the proposed fix to ensure theworkflow_dispatch-triggered release uses the operator-supplied version instead of falling back togithub.ref_name(the branch name):- name: Create GitHub Release uses: softprops/action-gh-release@v2 with: + tag_name: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} files: artifacts/* generate_release_notes: trueThis way, both push-tag and manual dispatch workflows will correctly target the intended release tag.