Skip to content
Merged
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
4 changes: 2 additions & 2 deletions openwisp_utils/releaser/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ def main():
["git", "checkout", "-b", release_branch], check=True, capture_output=True
)

print("Adding all changed files to git...")
subprocess.run(["git", "add", "."], check=True, capture_output=True)
print("Adding tracked changes to git...")
subprocess.run(["git", "add", "-u"], check=True, capture_output=True)
Comment on lines +361 to +362
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

git add -u still stages all tracked modified files, not just release files.

While git add -u is an improvement over git add ., it stages all tracked modified files in the repository, not just the changelog and version files modified by the release process. If a developer has other tracked files with uncommitted changes, those will be included in the release commit.

To fully address issue #552, explicitly stage only the files modified during the release process. The changelog file is always modified, and the version file(s) should be staged conditionally based on whether bump_version succeeded.

🔎 Recommended fix to stage only release-modified files
-    print("Adding tracked changes to git...")
-    subprocess.run(["git", "add", "-u"], check=True, capture_output=True)
+    # Stage only the files modified by the release process
+    print("Staging release files (changelog and version files)...")
+    subprocess.run(
+        ["git", "add", changelog_path], check=True, capture_output=True
+    )
+    if was_bumped and config.get("version_file"):
+        subprocess.run(
+            ["git", "add", config["version_file"]], check=True, capture_output=True
+        )

Note: You may need to verify the correct key/path for the version file in the config. If there are multiple version files or a different config structure, adjust accordingly.

Additional observation: The PR description mentions "Comments explaining selective staging were added," but no explanatory comments are present in the code changes.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
print("Adding tracked changes to git...")
subprocess.run(["git", "add", "-u"], check=True, capture_output=True)
# Stage only the files modified by the release process
print("Staging release files (changelog and version files)...")
subprocess.run(
["git", "add", changelog_path], check=True, capture_output=True
)
if was_bumped and config.get("version_file"):
subprocess.run(
["git", "add", config["version_file"]], check=True, capture_output=True
)
🧰 Tools
🪛 Ruff (0.14.10)

362-362: Starting a process with a partial executable path

(S607)

🤖 Prompt for AI Agents
In openwisp_utils/releaser/release.py around lines 361-362, the code uses "git
add -u" which stages all tracked modified files; change this to explicitly stage
only the changelog file and any version file(s) modified by the release. Modify
the logic to compute the changelog path (always) and, if bump_version succeeded,
determine the version file path(s) from the config and add them too; call
subprocess.run(["git","add", <path>], check=True, capture_output=True) for each
file instead of a single "git add -u". Also add brief comments explaining why we
selectively stage only release-modified files and that version files are added
conditionally when bump_version succeeds.


commit_message = f"{new_version} release"
subprocess.run(
Expand Down
Loading