-
Notifications
You must be signed in to change notification settings - Fork 0
- Added Version constant to define software version.
#10
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: main
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import ( | |
| ) | ||
|
|
||
| const ApiModel = "gpt-4o" // 128k context window | ||
| const Version = "0.0.1" | ||
|
|
||
| type GPTRequest struct { | ||
| Messages []GPTMessage `json:"messages"` | ||
|
|
@@ -67,6 +68,7 @@ func main() { | |
| rootCmd.AddCommand(generateCmd) | ||
| rootCmd.AddCommand(branchCmd) | ||
| rootCmd.AddCommand(prCmd) | ||
| rootCmd.AddCommand(versionCmd) | ||
| cobra.OnInitialize(initConfig) | ||
| if err := rootCmd.Execute(); err != nil { | ||
| color.Red(err.Error()) | ||
|
|
@@ -189,6 +191,14 @@ func initConfig() { | |
| } | ||
| } | ||
|
|
||
| var versionCmd = &cobra.Command{ | ||
|
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. This looks good is it fine the version is static? 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. Hey there! Thanks for taking a look at this code. Regarding your question about the static version, it's a valid point to bring up. While having a static version like this (const Version = "0.0.1") is common and can work well for small projects or rapid prototyping, there are some considerations we should think about. For production-grade software, especially if we're planning regular releases, it might be beneficial to implement a more dynamic versioning system. This could involve:
These approaches would ensure that the version always reflects the current state of the software without manual updates. However, if this is a small tool or we're in early development stages, the static version might be perfectly fine for now. We can always refactor this later if needed. What are your thoughts on this? Do you think we should implement a more dynamic versioning system now, or is the static version sufficient for our current needs? 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. Hi there! Thanks for bringing up this important point about versioning. I really appreciate your thoughtful analysis of the situation. I agree that the static versioning approach we're currently using has its limitations, especially as we think about the long-term maintainability and scalability of our project. Your suggestions for more dynamic versioning systems are spot on and align well with industry best practices. Given the context of our project, I think we should consider implementing a more robust versioning system sooner rather than later. Here's why:
I propose we implement a simple but effective solution using build-time variables. We could update our build process to inject the version number, something like: var Version string
// During build:
// go build -ldflags "-X main.Version=1.0.0"This approach is relatively straightforward to implement, provides the benefits of dynamic versioning, and doesn't require significant changes to our existing code structure. What do you think about this approach? If you agree, I'd be happy to create a separate task to implement this change. If you have any concerns or alternative suggestions, I'm all ears! 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. Hi there! Thank you for your detailed feedback and thoughtful analysis of our versioning approach. I really appreciate the time you've taken to consider the long-term implications of our current system. I completely agree with your assessment. You've made excellent points about scalability, automation, and traceability, which are all crucial factors we should consider as our project grows. Your proposal to use build-time variables is a solid, pragmatic solution that addresses these concerns without over-engineering at this stage. I particularly like how your suggested approach:
Implementing this change now is indeed a proactive step that will save us time and headaches down the line. I'm on board with creating a separate task for this implementation. To expand on your suggestion, we might also consider:
These additions could look like: var (
Version string
BuildTime string
GitCommit string
)
// During build:
// go build -ldflags "-X main.Version=1.0.0 -X main.BuildTime=$(date -u +'%Y-%m-%d_%H:%M:%S') -X main.GitCommit=$(git rev-parse HEAD)"What do you think about these additional fields? If you agree, I can include them in the implementation task. Let's move forward with this change. It's a great step towards more robust and maintainable code. Thanks again for bringing this up! |
||
| Use: "version", | ||
| Short: "Display the version", | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| fmt.Printf("GitPilotAI Version: %s\n", Version) | ||
| }, | ||
| } | ||
|
|
||
| var configCmd = &cobra.Command{ | ||
| Use: "config", | ||
| Short: "Configure the API key", | ||
|
|
@@ -331,21 +341,25 @@ func hasGitChanges() bool { | |
| return len(out) > 0 | ||
| } | ||
|
|
||
| // getGitDiff retrieves the staged and unstaged git diff. | ||
| func getGitDiff() string { | ||
| // Retrieve staged diff | ||
| stagedDiffCmd := exec.Command("git", "diff", "--staged") | ||
| stagedDiff, err := stagedDiffCmd.Output() | ||
| if err != nil { | ||
| color.Red("Error getting staged git diff: %v", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| // Retrieve unstaged diff | ||
| unstagedDiffCmd := exec.Command("git", "diff") | ||
| unstagedDiff, err := unstagedDiffCmd.Output() | ||
| if err != nil { | ||
| color.Red("Error getting unstaged git diff: %v", err) | ||
| os.Exit(1) | ||
| } | ||
|
|
||
| // Combine staged and unstaged diff | ||
| totalDiff := strings.TrimSpace(string(stagedDiff)) + "\n" + strings.TrimSpace(string(unstagedDiff)) | ||
| return totalDiff | ||
| } | ||
|
|
@@ -406,16 +420,6 @@ func makeOpenAIRequest(body []byte) (string, error) { | |
| } | ||
|
|
||
| func commitChanges(commitMessage string) error { | ||
| reader := bufio.NewReader(os.Stdin) | ||
| fmt.Print("Are you sure you want to commit the changes? (y/n): ") | ||
| fmt.Printf("%s\n", commitMessage) | ||
| confirmation, _ := reader.ReadString('\n') | ||
| confirmation = strings.TrimSpace(confirmation) | ||
|
|
||
| if confirmation != "y" && confirmation != "Y" { | ||
| color.Yellow("Commit canceled.") | ||
| return nil | ||
| } | ||
| cmd := exec.Command("git", "commit", "-m", commitMessage) | ||
| if out, err := cmd.CombinedOutput(); err != nil { | ||
| color.Red("git commit failed: %s, %v", out, err) | ||
|
|
||
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.
is this correct using semantic versioning?
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.
Hey there! Thanks for bringing up the question about semantic versioning. It's a great point to consider, especially for a package that might be used by other developers.
Looking at the code context you've provided, I don't see any explicit version information. Semantic versioning typically applies to how we tag and release our software, rather than something we'd see directly in the source code like this.
That being said, it's an excellent reminder that we should ensure our project is following semantic versioning principles when we release it. This would involve:
If you're concerned about how we're managing versions for this project, we could consider adding a VERSION constant in the code or using a separate version file. This could help us keep track of the current version and ensure we're updating it appropriately with each release.
Do you have any specific concerns about versioning for this package? Or were you thinking of a particular part of the code where version information should be added? I'd be happy to discuss this further and come up with a solid versioning strategy for our project.
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.
Testing for context