Skip to content

Commit

Permalink
Merge pull request #58 from minnek-digital-studio/feature/55
Browse files Browse the repository at this point in the history
feature/55
  • Loading branch information
Isaac Martinez authored Mar 12, 2023
2 parents 0bebfc3 + e42a6fe commit 8c5a0c2
Show file tree
Hide file tree
Showing 18 changed files with 190 additions and 136 deletions.
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
#
# Change the owner's username with the project lead.
* @isaacismaelx14
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Tests
on: [pull_request]

permissions:
contents: read

jobs:
build:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19

- name: Check out code
uses: actions/checkout@v3

- name: Restore Go modules cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }}
restore-keys: |
go-${{ runner.os }}-
- name: Download dependencies
run: go mod download

# - name: Run tests
# run: go test -race ./...

- name: Build
run: go build -v ./...
45 changes: 17 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
Create commits & pull requests easily. `Cominnek` is based on the [Semantic Commit Messages](https://www.conventionalcommits.org/en/v1.0.0/) specification.
## Index
- **[Requirements](#requirements)**
- **[Git-Flow](#git-flow)**
- **[Install](#installation)**
- **[First Step](#first-steps)**
- **[Usage](#usage)**
Expand All @@ -25,22 +24,6 @@ Create commits & pull requests easily. `Cominnek` is based on the [Semantic Comm
# Requirements

- **[Git](https://git-scm.com/)**
- **[Git-Flow](#git-flow)**

### Git-Flow
To install git flow run:

#### MacOS

```bash
brew install git-flow
```

#### Linux

```bash
sudo apt install git-flow
```

# Installation

Expand Down Expand Up @@ -94,7 +77,7 @@ cominnek auth test
- **[Push](#push)**: Commit and push the branch to GitHub.
- **[Publish](#publish)**: Commit, push and create the pull request as a draft to develop in GitHub.
- **[Commit](#commit)**: Commit the changes to the branch.
- **[Flow](#flow)**: Create a new branch and start the flow.
- **[Branch](#branch)**: Create a new branch.
- **[Stash](#stash)**: Stash changes from one branch to another one.
- **[PR](#pr)**: Create a Pull Request as a draft to develop in GitHub.
- **[Merge](#merge)**: Merge the branch into the received branch.
Expand Down Expand Up @@ -179,20 +162,23 @@ the commit will be: `feat(home):{Ticket} do some modifications`
| ` --revert` |string | make the commit with the prefix revert()|

*\* required*
## Flow
## Branch
Create a new branch with the prefix `feature/`, `bugfix/`, `hotfix/` or `release/` and the name of the branch will be the ticket number.

At Minnek, we created a variant of Git-flow where the main difference is that we don't merge the branch upon completion. Instead, we create a Github Pull Request.

```bash
cominnek flow feature "<Ticket>"
cominnek branch feature "<Ticket>"
```
This the equivalent of: `git flow feature start {Ticket}` or `git-flow feature start {Ticket}` on MacOS
This the equivalent of: `git branch feature/{Ticket}`

| Command | description |
| ------------------ | ---------------------------------------|
| `feature` | create a new feature branch |
| `bugfix` | create a new bugfix branch |
| `hotfix` | create a new hotfix branch |
| `release` | create a new release branch |
| `feature` | create a new feature branch from `develop` |
| `bugfix` | create a new bugfix branch from `develop` |
| `hotfix` | create a new hotfix branch from `master`|
| `release` | create a new release branch from `develop`|
| `support` | create a new support branch from `master`|

| Flag | type | description |
| ------------------ | ------------- | ---------------------------------------|
Expand All @@ -219,9 +205,12 @@ cominnek pr
```
The flag `--ticket` is optional. If it's not provided this will take the ticket number from the current branch.

| flag | type | description |
| ------------------ | ------------- | ---------------------------------------|
| `-t --ticket` |string | name of the feature that's will be applied the change |
| flag | type | default | description |
| ------------------ | ------------- | ------ | ---------------------------------------|
| `-t --ticket` |string | take by branch| name of the feature that's will be applied the change |
| `-b --base` |string | `develop` | base branch of the pull request. |

In a case of a release branch, it will create a pull request to `master` and `develop`.

## Merge
Merge the current branch into the received one. This will help you save time when you are working on a feature branch and you want to merge, for example, the feature branch into the `test` branch.
Expand Down
25 changes: 25 additions & 0 deletions cmd/branch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

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

var branchCmd = &cobra.Command{
Use: "branch",
Short: "Create a new branch. This is variant of git-flow by Minnek",
Run: func(cmd *cobra.Command, args []string) {
pkg_action.Branch()
},
}

func init() {
branch.SetFlags()
branchCmd.AddCommand(branch.BranchFeatureCmd)
branchCmd.AddCommand(branch.BranchReleaseCmd)
branchCmd.AddCommand(branch.BranchHotfixCmd)
branchCmd.AddCommand(branch.BranchSupportCmd)
branchCmd.AddCommand(branch.BranchBugfixCmd)
rootCmd.AddCommand(branchCmd)
}
12 changes: 6 additions & 6 deletions cmd/flow/bugfix.go → cmd/branch/bugfix.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package flow
package branch

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

var FlowBugfixCmd = &cobra.Command{
var BranchBugfixCmd = &cobra.Command{
Use: "bugfix <name>",
Short: "create a new feature branch",
Short: "create a new feature branch from develop",
Run: func(cmd *cobra.Command, args []string) {
config.AppData.Flow.Type = "bugfix"
config.AppData.Flow.Stash = stash
config.AppData.Branch.Type = "bugfix"
config.AppData.Branch.Stash = stash
setTicket(args)

pkg_action.Flow()
pkg_action.Branch()
},
}
12 changes: 6 additions & 6 deletions cmd/flow/feature.go → cmd/branch/feature.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package flow
package branch

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

var FlowFeatureCmd = &cobra.Command{
var BranchFeatureCmd = &cobra.Command{
Use: "feature <name>",
Short: "create a new feature branch",
Short: "create a new feature branch from develop",
Run: func(cmd *cobra.Command, args []string) {
config.AppData.Flow.Type = "feature"
config.AppData.Flow.Stash = stash
config.AppData.Branch.Type = "feature"
config.AppData.Branch.Stash = stash
setTicket(args)

pkg_action.Flow()
pkg_action.Branch()
},
}
12 changes: 6 additions & 6 deletions cmd/flow/hotfix.go → cmd/branch/hotfix.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package flow
package branch

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

var FlowHotfixCmd = &cobra.Command{
var BranchHotfixCmd = &cobra.Command{
Use: "hotfix <name>",
Short: "create a new hotfix branch",
Short: "create a new hotfix branch from master",
Run: func(cmd *cobra.Command, args []string) {
config.AppData.Flow.Type = "hotfix"
config.AppData.Flow.Stash = stash
config.AppData.Branch.Type = "hotfix"
config.AppData.Branch.Stash = stash
setTicket(args)

pkg_action.Flow()
pkg_action.Branch()
},
}
14 changes: 7 additions & 7 deletions cmd/flow/main.go → cmd/branch/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package flow
package branch

import (
"github.com/Minnek-Digital-Studio/cominnek/config"
Expand All @@ -8,11 +8,11 @@ import (
var stash bool

func SetFlags() {
addFlags(FlowFeatureCmd)
addFlags(FlowReleaseCmd)
addFlags(FlowHotfixCmd)
addFlags(FlowSupportCmd)
addFlags(FlowBugfixCmd)
addFlags(BranchFeatureCmd)
addFlags(BranchReleaseCmd)
addFlags(BranchHotfixCmd)
addFlags(BranchSupportCmd)
addFlags(BranchBugfixCmd)
}

func addFlags(cmd *cobra.Command) {
Expand All @@ -21,6 +21,6 @@ func addFlags(cmd *cobra.Command) {

func setTicket(args []string) {
if len(args) > 0 {
config.AppData.Flow.Ticket = args[0]
config.AppData.Branch.Ticket = args[0]
}
}
12 changes: 6 additions & 6 deletions cmd/flow/release.go → cmd/branch/release.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package flow
package branch

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

var FlowReleaseCmd = &cobra.Command{
var BranchReleaseCmd = &cobra.Command{
Use: "release <name>",
Short: "create a new release branch",
Short: "create a new release branch from develop",
Run: func(cmd *cobra.Command, args []string) {
config.AppData.Flow.Type = "release"
config.AppData.Flow.Stash = stash
config.AppData.Branch.Type = "release"
config.AppData.Branch.Stash = stash
setTicket(args)

pkg_action.Flow()
pkg_action.Branch()
},
}
12 changes: 6 additions & 6 deletions cmd/flow/support.go → cmd/branch/support.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package flow
package branch

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

var FlowSupportCmd = &cobra.Command{
var BranchSupportCmd = &cobra.Command{
Use: "support <name>",
Short: "create a new support branch",
Short: "create a new support branch from master",
Run: func(cmd *cobra.Command, args []string) {
config.AppData.Flow.Type = "support"
config.AppData.Flow.Stash = stash
config.AppData.Branch.Type = "support"
config.AppData.Branch.Stash = stash
setTicket(args)

pkg_action.Flow()
pkg_action.Branch()
},
}
25 changes: 0 additions & 25 deletions cmd/flow.go

This file was deleted.

2 changes: 1 addition & 1 deletion config/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type IAppData struct {
Ticket string
Base string
}
Flow struct {
Branch struct {
Type string
Ticket string
Stash bool
Expand Down
27 changes: 27 additions & 0 deletions controllers/git/branch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package git_controller

import "fmt"

func getBaseCmd(branch string) string {
return fmt.Sprintf("git branch %s; git checkout %s", branch, branch)
}

func Feature(ticket string) string {
return getBaseCmd("feature/" + ticket)
}

func Bugfix(ticket string) string {
return getBaseCmd("bugfix/" + ticket)
}

func Hotfix(ticket string) string {
return getBaseCmd("hotfix/" + ticket)
}

func Release(ticket string) string {
return getBaseCmd("release/" + ticket)
}

func Support(ticket string) string {
return getBaseCmd("support/" + ticket)
}
Loading

0 comments on commit 8c5a0c2

Please sign in to comment.