Skip to content

Conversation

@Atmois
Copy link
Contributor

@Atmois Atmois commented Sep 6, 2024

Description

Add author to issue body

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other: (write here)

Guidelines

  • My code follows the style guidelines of this project (formatted with Ruff)

  • I have performed a self-review of my own code

  • I have commented my code, particularly in hard-to-understand areas

  • I have made corresponding changes to the documentation if needed

  • My changes generate no new warnings

  • I have tested this change

  • Any dependent changes have been merged and published in downstream modules

  • I have followed all of these guidelines.

How Has This Been Tested? (if applicable)

yes, it works

Screenshots (if applicable)

image

Additional Information

fixes #494

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 6, 2024

Reviewer's Guide by Sourcery

This pull request adds the author's name to the issue body when creating a new issue using the bot. The change is implemented in the create_issue method of the admin/git cog.

File-Level Changes

Change Details Files
Add author information to the issue body
  • Concatenate the original body with the author's name
  • Update the issue creation call to use the new issue body
  • Update the success embed to display the new issue body
tux/cogs/admin/git.py

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@Atmois
Copy link
Contributor Author

Atmois commented Sep 6, 2024

we are sooooo back

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Atmois - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Could you provide more details on how this change was tested? A brief description of the test cases or scenarios you used would be helpful.
Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.


try:
created_issue = await self.github.create_issue(title, body)
issue_body = body + "\n\nAuthor: " + str(ctx.author)
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider using a more structured approach for adding author information

Instead of appending the author information directly to the body, consider using GitHub's API to set it as a custom field or label if possible. Alternatively, you could add a structured metadata section at the end of the body, which would be easier to parse programmatically if needed.

Suggested change
issue_body = body + "\n\nAuthor: " + str(ctx.author)
metadata = {
"Author": str(ctx.author),
"Created-By": "Discord Bot"
}
metadata_str = "\n".join(f"{k}: {v}" for k, v in metadata.items())
issue_body = f"{body}\n\n---\n{metadata_str}"

embed.add_field(name="Body", value=body, inline=False)
embed.add_field(name="Body", value=issue_body, inline=False)

except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Add error logging for better debugging and monitoring

Before sending the error message to the user, consider adding proper error logging. This will help with debugging and monitoring the application's behavior.

Suggested change
except Exception as e:
except Exception as e:
logging.error(f"Error creating issue: {e}", exc_info=True)

@kzndotsh kzndotsh merged commit e7004b2 into main Sep 6, 2024
@kzndotsh kzndotsh deleted the gitcreateimprovements branch September 6, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

show name of user submitting issue through discord on issue

3 participants