Skip to content

Commit

Permalink
Merge pull request #39 from Minnek-Digital-Studio/release/2.4.0
Browse files Browse the repository at this point in the history
release/2.4.0 master
  • Loading branch information
Isaac Martinez authored Nov 12, 2022
2 parents a102fc5 + 22db17a commit 2c9ffab
Show file tree
Hide file tree
Showing 16 changed files with 136 additions and 46 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ sudo apt install git-flow

1. Download installer

[![Macos](https://img.shields.io/badge/mac%20os-0078D6?style=for-the-badge&logo=apple&logoColor=white)](https://github.com/Minnek-Digital-Studio/cominnek/releases/latest/download/cominnek-2.3.1.dmg) [![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white
)](https://github.com/Minnek-Digital-Studio/cominnek/releases/latest/download/cominnek-2.3.1.exe) [![Linux](https://img.shields.io/badge/Linux-0078D6?style=for-the-badge&logo=linux&logoColor=white)](https://github.com/Minnek-Digital-Studio/cominnek/releases/latest/download/cominnek-2.3.1.deb)
[![Macos](https://img.shields.io/badge/mac%20os-0078D6?style=for-the-badge&logo=apple&logoColor=white)](https://github.com/Minnek-Digital-Studio/cominnek/releases/latest/download/cominnek-2.4.0.dmg) [![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white
)](https://github.com/Minnek-Digital-Studio/cominnek/releases/latest/download/cominnek-2.4.0.exe) [![Linux](https://img.shields.io/badge/Linux-0078D6?style=for-the-badge&logo=linux&logoColor=white)](https://github.com/Minnek-Digital-Studio/cominnek/releases/latest/download/cominnek-2.4.0.deb)

2. Run installer ([See MAC Os steps](#how-to-install-on-mac))

Expand Down Expand Up @@ -111,7 +111,7 @@ Create and push a commit with the correct template for conventional commits.
```bash
cominnek update-version <version>
```
the commit will be: `build(version): update version`
the commit will be: `build: update version to <version>`

| flag | type | description |
| ------------------ | ------------- | --------------------------- |
Expand Down Expand Up @@ -140,6 +140,8 @@ the commit will be: `fix(home):{Ticket} do some modifications`
| ` --ci` |string | make the commit with the prefix ci() |
| ` --chore` |string | make the commit with the prefix chore()|
| ` --revert` |string | make the commit with the prefix revert()|
| ` --skip-commit` |string | Skip the commit and only push the branch|


*\* required*

Expand Down Expand Up @@ -373,7 +375,7 @@ $ cominnek push "Changes in home page" -F "home"
If you want to contribute to this project, please read the [contributing guide](/CONTRIBUTING.md)
Cominnek `V2.3.1`
Cominnek `V2.4.0`
> With ❤ by [isaacismaelx14](https://github.com/isaacismaelx14)
## About
Expand Down
2 changes: 1 addition & 1 deletion assets/windows/bin/setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#include "environment.iss"
#define MyAppName "Cominnek"
#define MyAppVersion "2.3.1"
#define MyAppVersion "2.4.0"
#define MyAppPublisher "Minnek Digital Studio"
#define MyAppURL "https://github.com/Minnek-Digital-Studio/cominnek"
#define MyAppExeName "cominnek.exe"
Expand Down
1 change: 1 addition & 0 deletions cmd/addFlags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func (x AddFlags) Commit(_cmd *cobra.Command) {
_cmd.PersistentFlags().StringVarP(&ci, "ci", "", "", "Changes to our CI configuration files and scripts ⚙️")
_cmd.PersistentFlags().StringVarP(&chore, "chore", "c", "", "Other changes that don't modify src or test files ♻️")
_cmd.PersistentFlags().StringVarP(&revert, "revert", "", "", "Reverts a previous commit 🗑")
_cmd.PersistentFlags().BoolVarP(&addAll, "all", "a", false, "Add all files changed to commit")
}

func (x AddFlags) Push(_cmd *cobra.Command) {
Expand Down
1 change: 0 additions & 1 deletion cmd/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ var commitCmd = &cobra.Command{
}

func init() {
commitCmd.PersistentFlags().BoolVarP(&addAll, "all", "a", false, "Add all files changed to commit")
AddFlags{}.Commit(commitCmd)
rootCmd.AddCommand(commitCmd)
}
Expand Down
11 changes: 7 additions & 4 deletions cmd/merge.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
package cmd

import (
"github.com/Minnek-Digital-Studio/cominnek/pkg/git"
"github.com/Minnek-Digital-Studio/cominnek/config"
pkg_action "github.com/Minnek-Digital-Studio/cominnek/pkg/cli/actions"
"github.com/spf13/cobra"
)

var mergeCmd = &cobra.Command{
Use: "merge <branch>",
Args: cobra.ExactArgs(1),
Short: "Merge a branch into the current branch",
Long: `Merge a branch into the current branch. This command will
merge the current branch into the branch specified. This command
will not work if there are any conflicts. If there are conflicts,
you will need to resolve them before running this command.`,
Run: func(cmd *cobra.Command, args []string) {
branch := args[0]
git.Merge(branch)
if len(args) > 0 {
config.AppData.Merge.Branch = args[0]
}

pkg_action.Merge()
},
}

Expand Down
2 changes: 2 additions & 0 deletions cmd/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var publishCmd = &cobra.Command{
config.AppData.Commit.Body = body
config.AppData.Push.Merge = merge
config.AppData.Publish.Ticket = ticket
config.AppData.Push.IgnoreCommit = skipCommit

pkg_action.Publish()

Expand All @@ -41,5 +42,6 @@ var publishCmd = &cobra.Command{
func init() {
AddFlags{}.Push(publishCmd)
publishCmd.PersistentFlags().StringVarP(&ticket, "ticket", "t", "", "Ticket number")
publishCmd.Flags().BoolVar(&skipCommit, "skip-commit", false, "Skip the commit and only push the branch")
rootCmd.AddCommand(publishCmd)
}
4 changes: 4 additions & 0 deletions cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/spf13/cobra"
)

var skipCommit bool

var pushCmd = &cobra.Command{
Use: "push <message>",
Short: "push a branch to GitHub",
Expand All @@ -27,12 +29,14 @@ var pushCmd = &cobra.Command{
config.AppData.Commit.Type = ctype
config.AppData.Commit.Body = body
config.AppData.Push.Merge = merge
config.AppData.Push.IgnoreCommit = skipCommit

pkg_action.Push()
},
}

func init() {
pushCmd.Flags().BoolVar(&skipCommit, "skip-commit", false, "Skip the commit and only push the branch")
AddFlags{}.Push(pushCmd)
rootCmd.AddCommand(pushCmd)
}
11 changes: 8 additions & 3 deletions config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ type IAppData struct {
Scope string
}
Push struct {
Merge string
Merge string
IgnoreCommit bool
}
Publish struct {
Ticket string
Ticket string
IgnoreCommit bool
}
PullRequest struct {
Ticket string
Expand All @@ -37,6 +39,9 @@ type IAppData struct {
Stash struct {
Branch string
}
Merge struct {
Branch string
}
}

type IConfig struct {
Expand All @@ -57,7 +62,7 @@ var cominnekPath = filepath.Join(userPath, ".cominnek")
var cominnekTempPath = filepath.Join(tempPath, ".cominnek")

var Public = IConfig{
Version: "v2.3.1",
Version: "v2.4.0",
KeyPath: filepath.Join(cominnekPath, "key.bin"),
TokenPath: filepath.Join(cominnekPath, "auth.bin"),
PRBody: filepath.Join(cominnekPath, "pr-body.md"),
Expand Down
16 changes: 16 additions & 0 deletions controllers/git/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package git_controller
import (
"fmt"
"strings"

"github.com/Minnek-Digital-Studio/cominnek/pkg/shell"
)

func _removeTwoSpaces(str string) string {
Expand All @@ -19,6 +21,20 @@ func _getCommitMessage(msg string, ctype string, ticket string, scope string) st
return _removeTwoSpaces(commit_message)
}

func CheckChanges() bool {
out, _, err := shell.Out(Status())

if err != nil {
return false
}

if out == "" {
return false
}

return true
}

func Commit(msg string, _body string, ctype string, tiket string, scope string) string {
trimScope := strings.TrimSpace(scope)
body := strings.TrimSpace(_body)
Expand Down
3 changes: 3 additions & 0 deletions controllers/git/pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ func Pull_request(ticket string, branch string) string {
body := string(bodyByte)

msg := helper.ReplaceValues(body, variables)
msg = msg + `
<small>Created with <a href="https://github.com/Minnek-Digital-Studio/cominnek" target="_blank">Cominnek 🔥</a></small>`

return msg
}
48 changes: 21 additions & 27 deletions helper/PRBody.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,42 +36,36 @@ var _variables []Variables = []Variables{
Variable: "${#developer}",
Value: "`developer`",
},
{
Variable: "${#checks}",
Value: "`checks`",
},
}

var _PRBody string = `
# Ticket information:
[![Jira](https://img.shields.io/badge/Jira-0052CC?style=for-the-badge&logo=Jira&logoColor=white)](https://minnek.atlassian.net/browse/${ticket})
## Issue Info
- ${ticket}
<a href="https://minnek.atlassian.net/browse/${ticket}" target="_blank">
<img src="https://img.shields.io/badge/Jira-0052CC?style=for-the-badge&logo=Jira&logoColor=white" alt="JIRA" title="${ticket}"/>
</a>
### Code Review Checklist
### Code Review Checklist for Authors
- [ ] Update your branch with latest changes from ${#develop}
- [ ] Verify all the checks are passed (if applicable)
- [ ] Use clean code practices
- [ ] Everything sorted alphabetically
- [ ] Use ${#rem} not ${#px}
- [ ] Instructions for how reviewers can test the code locally
- [ ] Screenshot of the feature/bug fix (if applicable)
- [ ] If any new text is added, it's internationalized, use ${#lang} function
- [ ] Any new elements have aria labels (accessibility)
- [ ] No unintentional ${#clg} left behind after debugging
- [ ] Did I use the clear and concise names for variables and functions?
- [ ] Did I explain all possible solutions and why I chose the one I did?
- [ ] Added any comments to make new functions clearer
- [ ] Comment the code if it's really needed (the code show be self-explained)
- [ ] Added PR labels
- [ ] Update any history/changelog file
- [ ] Update your branch with the latest changes from ${#develop}.
- [ ] Verify all the ${#checks} are passed (if applicable).
- [ ] Use [code conventions](https://en.wikipedia.org/wiki/Coding_conventions) and [best practices](https://en.wikipedia.org/wiki/Best_practice).
- [ ] New features must have compatibility for a11y (Accessibility).
- [ ] No unintentional ${#clg} left behind after debugging.
- [ ] Notify the code reviewers on time to have an efficient review time.
>**In case something is not applied, justify the reason why you skip one of the points above**
### Code Review Checklist for Reviewers
#### Notes before Merge
- [ ] Take some time to understand the code you are reading.
- [ ] Use an inquisitive tone, do not make an order.
- [ ] Accept that many programming decisions are opinions. Engage a discussion and reach a resolution quickly.
- [ ] Seek to understand the author’s perspective.
- Change pull request title to ${#feature-ticket} to match the branch name. See the docs [here](https://github.com/Minnek-Digital-Studio/minnek-developer-handbook/blob/master/development/git-version-control.md#pull-request).
- Write Short and Detailed Commit Messages. See the docs [here](https://github.com/Minnek-Digital-Studio/minnek-developer-handbook/blob/master/development/git-version-control.md#writing-commits).
- Set a ${#developer}, to Code Review this pull request before merge to the ${#develop} branch. See the docs [here](https://github.com/Minnek-Digital-Studio/minnek-developer-handbook/blob/master/development/code-review.md).
- Follow these Guides for Coding Standard: [SASS](https://github.com/bigcommerce/sass-style-guide), [JavaScript](https://developer.mozilla.org/en-US/docs/MDN/Guidelines/Code_guidelines/JavaScript) and [HTML5](https://developer.mozilla.org/en-US/docs/MDN/Guidelines/Code_guidelines/HTML#class_and_id_names).
**In case something is not applied, justify the reason why you skip one of the points above**
`

func ReplaceValues(base string, origin []Variables) string {
Expand Down
5 changes: 5 additions & 0 deletions pkg/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func askActions() {
actions := []string{
"Commit",
"Create Branch",
"Merge",
"Pull Request",
"Publish",
"Push",
Expand Down Expand Up @@ -54,4 +55,8 @@ func askActions() {
if config.AppData.Action == "Stash" {
pkg_action.Stash()
}

if config.AppData.Action == "Merge" {
pkg_action.Merge()
}
}
38 changes: 38 additions & 0 deletions pkg/cli/actions/merge.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package pkg_action

import (
"github.com/AlecAivazis/survey/v2"
"github.com/Minnek-Digital-Studio/cominnek/config"
git_controller "github.com/Minnek-Digital-Studio/cominnek/controllers/git"
"github.com/Minnek-Digital-Studio/cominnek/controllers/loading"
"github.com/Minnek-Digital-Studio/cominnek/pkg/ask"
"github.com/Minnek-Digital-Studio/cominnek/pkg/git"
)

func mergeQuestions() {
if config.AppData.Merge.Branch == "" {
loading.Start("Reading branches...")
branches := git_controller.ListBranches()
currentBranch := git_controller.GetCurrentBranch()

for i, branch := range branches {
if branch == currentBranch {
branches = append(branches[:i], branches[i+1:]...)
break
}
}

loading.Stop()

ask.One(&survey.Select{
Message: "Select a branch to merge your changes into:",
Options: branches,
}, &config.AppData.Merge.Branch, survey.WithValidator(survey.Required))
}
}

func Merge() {
mergeQuestions()
git.Merge(config.AppData.Merge.Branch)

}
13 changes: 11 additions & 2 deletions pkg/cli/actions/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,21 @@ func publishQuestions() {
}

func Publish() {
Commit(false)
if !config.AppData.Publish.IgnoreCommit {
config.AppData.Publish.IgnoreCommit = !git_controller.CheckChanges()
}

if !config.AppData.Publish.IgnoreCommit {
Commit(false)
}

pushQuestion()
publishQuestions()

executeCommit()
if !config.AppData.Publish.IgnoreCommit {
executeCommit()
}

github.Publish(config.AppData.Publish.Ticket)

if config.AppData.Push.Merge != "" {
Expand Down
13 changes: 11 additions & 2 deletions pkg/cli/actions/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,20 @@ func pushQuestion() {
}

func Push() {
Commit(false)
if !config.AppData.Push.IgnoreCommit {
config.AppData.Push.IgnoreCommit = !git_controller.CheckChanges()
}

if !config.AppData.Push.IgnoreCommit {
Commit(false)
}

pushQuestion()

executeCommit()
if !config.AppData.Push.IgnoreCommit {
executeCommit()
}

git.Push()

if config.AppData.Push.Merge != "" {
Expand Down
4 changes: 2 additions & 2 deletions pkg/extras/update_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func UpdateVersion(version string) {
msg := "update version"
msg := "update version to " + version

git.PushWithOutTicket(msg, "", "build", version)
git.PushWithOutTicket(msg, "", "build", "")
}

0 comments on commit 2c9ffab

Please sign in to comment.