Skip to content

Commit 2d61e1a

Browse files
feat: added pull message in ui
1 parent 0b485d0 commit 2d61e1a

File tree

5 files changed

+194
-41
lines changed

5 files changed

+194
-41
lines changed

.github/workflos/build.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Build and Release Froggit
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
name: Build ${{ matrix.os }}-${{ matrix.arch }}
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
os: [linux, windows, darwin]
17+
arch: [amd64, arm64]
18+
exclude:
19+
- os: windows
20+
arch: arm64
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: 1.22
30+
31+
- name: Build binary
32+
env:
33+
GOOS: ${{ matrix.os }}
34+
GOARCH: ${{ matrix.arch }}
35+
run: |
36+
mkdir -p dist
37+
BIN_NAME="froggit-${{ matrix.os }}-${{ matrix.arch }}"
38+
[[ "${{ matrix.os }}" == "windows" ]] && BIN_NAME="$BIN_NAME.exe"
39+
go build -o "$BIN_NAME" .
40+
zip -j "dist/${{ matrix.os }}-${{ matrix.arch }}.zip" "$BIN_NAME"
41+
42+
- name: Upload artifact for release
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: froggit-${{ matrix.os }}-${{ matrix.arch }}
46+
path: dist/${{ matrix.os }}-${{ matrix.arch }}.zip
47+
48+
release:
49+
name: Create GitHub Release
50+
needs: build
51+
runs-on: ubuntu-latest
52+
53+
steps:
54+
- name: Download all artifacts
55+
uses: actions/download-artifact@v4
56+
with:
57+
path: artifacts
58+
59+
- name: Create GitHub Release
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
name: Froggit ${{ github.ref_name }}
63+
tag_name: ${{ github.ref_name }}
64+
files: |
65+
artifacts/**/**/*.zip
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

internal/git/git.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,21 @@ func DiscardChanges(filename string) error {
229229
fmt.Println("Cambios descartados correctamente")
230230
return nil
231231
}
232+
233+
// HasRemoteChanges verifica si hay commits pendientes de pull desde el remoto
234+
func HasRemoteChanges(branch string) (bool, error) {
235+
// Ejecuta git fetch para actualizar refs
236+
err := Fetch()
237+
if err != nil {
238+
return false, err
239+
}
240+
241+
cmd := exec.Command("git", "rev-list", "--count", fmt.Sprintf("HEAD..origin/%s", branch))
242+
output, err := cmd.Output()
243+
if err != nil {
244+
return false, err
245+
}
246+
247+
count := strings.TrimSpace(string(output))
248+
return count != "0", nil
249+
}

internal/tui/model/model.go

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,25 @@ const (
2020
)
2121

2222
type Model struct {
23-
Files []git.FileItem
24-
Branches []string
25-
Remotes []string
26-
CurrentBranch string
27-
Cursor int
28-
CurrentView View
29-
CommitMsg string
30-
RemoteName string
31-
RemoteURL string
32-
InputField string
33-
Message string
34-
MessageType string
35-
IsPushing bool
36-
SpinnerIndex int
37-
SpinnerFrames []string
38-
IsFetching bool
39-
IsPulling bool
40-
NewBranchName string
23+
Files []git.FileItem
24+
Branches []string
25+
Remotes []string
26+
CurrentBranch string
27+
Cursor int
28+
CurrentView View
29+
CommitMsg string
30+
RemoteName string
31+
RemoteURL string
32+
InputField string
33+
Message string
34+
MessageType string
35+
IsPushing bool
36+
SpinnerIndex int
37+
SpinnerFrames []string
38+
IsFetching bool
39+
IsPulling bool
40+
NewBranchName string
41+
HasRemoteChanges bool
4142

4243
DialogType string
4344
DialogTarget string
@@ -47,38 +48,42 @@ func InitialModel() Model {
4748
files, _ := git.GetModifiedFiles()
4849
branches, current := git.GetBranches()
4950
remotes, _ := git.GetRemotes()
51+
hasRemoteChanges, _ := git.HasRemoteChanges(current)
5052

5153
return Model{
52-
Files: files,
53-
Branches: branches,
54-
Remotes: remotes,
55-
CurrentBranch: current,
56-
Cursor: 0,
57-
CurrentView: FileView,
58-
CommitMsg: "",
59-
RemoteName: "",
60-
RemoteURL: "",
61-
InputField: "",
62-
Message: "",
63-
MessageType: "",
64-
SpinnerFrames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
65-
IsPushing: false,
66-
SpinnerIndex: 0,
67-
IsFetching: false,
68-
IsPulling: false,
69-
NewBranchName: "",
70-
DialogType: "",
71-
DialogTarget: "",
54+
Files: files,
55+
Branches: branches,
56+
Remotes: remotes,
57+
CurrentBranch: current,
58+
Cursor: 0,
59+
CurrentView: FileView,
60+
CommitMsg: "",
61+
RemoteName: "",
62+
RemoteURL: "",
63+
InputField: "",
64+
Message: "",
65+
MessageType: "",
66+
SpinnerFrames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"},
67+
IsPushing: false,
68+
SpinnerIndex: 0,
69+
IsFetching: false,
70+
IsPulling: false,
71+
NewBranchName: "",
72+
HasRemoteChanges: hasRemoteChanges,
73+
DialogType: "",
74+
DialogTarget: "",
7275
}
7376
}
7477

7578
func (m *Model) RefreshData() {
7679
files, _ := git.GetModifiedFiles()
7780
branches, current := git.GetBranches()
7881
remotes, _ := git.GetRemotes()
82+
hasRemoteChanges, _ := git.HasRemoteChanges(current)
7983

8084
m.Files = files
8185
m.Branches = branches
8286
m.Remotes = remotes
8387
m.CurrentBranch = current
88+
m.HasRemoteChanges = hasRemoteChanges
8489
}

internal/tui/styles/styles.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ var (
3939
Bold(true).
4040
Padding(0, 1)
4141

42+
WarningStyle = lipgloss.NewStyle().
43+
Foreground(lipgloss.Color("214")).
44+
// Background(lipgloss.Color("235")).
45+
Bold(true).
46+
Padding(0, 1)
47+
4248
SuccessStyle = lipgloss.NewStyle().
4349
Foreground(lipgloss.Color(Green)).
4450
Background(lipgloss.Color("236")).
@@ -64,4 +70,57 @@ var (
6470
SpinnerStyle = lipgloss.NewStyle().
6571
Foreground(lipgloss.Color(Green)).
6672
Bold(true)
73+
74+
ControlTitleStyle = lipgloss.NewStyle().
75+
Foreground(lipgloss.Color(Green)).
76+
Bold(true).
77+
MarginBottom(1)
78+
79+
ControlSectionStyle = lipgloss.NewStyle().
80+
Foreground(lipgloss.Color("245")).
81+
Bold(true).
82+
MarginTop(1)
83+
84+
ControlKeyStyle = lipgloss.NewStyle().
85+
Foreground(lipgloss.Color(DarkGreen)).
86+
Bold(true)
87+
88+
ControlDescStyle = lipgloss.NewStyle().
89+
Foreground(lipgloss.Color("249"))
90+
91+
// Estilo para el contenedor de controles
92+
ControlsBoxStyle = lipgloss.NewStyle().
93+
Border(lipgloss.RoundedBorder()).
94+
BorderForeground(lipgloss.Color(Gray)).
95+
Padding(1, 2).
96+
Margin(1, 0).
97+
Width(60) // Ancho fijo para mejor alineación
98+
PanelStyle = lipgloss.NewStyle().
99+
Border(lipgloss.NormalBorder()).
100+
BorderForeground(lipgloss.Color(Gray)).
101+
Padding(0, 1).
102+
Margin(0, 1)
103+
104+
ActivePanelStyle = lipgloss.NewStyle().
105+
Border(lipgloss.NormalBorder()).
106+
BorderForeground(lipgloss.Color(Green)).
107+
Padding(0, 1).
108+
Margin(0, 1)
109+
110+
PanelTitleStyle = lipgloss.NewStyle().
111+
Foreground(lipgloss.Color(Green)).
112+
Bold(true).
113+
Padding(0, 1).
114+
Background(lipgloss.Color(Gray))
115+
116+
StatusBarStyle = lipgloss.NewStyle().
117+
Foreground(lipgloss.Color(LightGray)).
118+
Background(lipgloss.Color("235")).
119+
Padding(0, 1).
120+
Width(100) // Ajustar según el ancho de tu terminal
121+
122+
// Para el layout horizontal
123+
MainContentStyle = lipgloss.NewStyle().
124+
Width(80).
125+
Height(25) // Ajustar según la altura de tu terminal
67126
)

internal/tui/views/file_view.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ func RenderFileView(m model.Model) string {
2222
}
2323
}
2424

25-
s.WriteString(styles.HeaderStyle.Render(" Git Status:") + "\n")
26-
s.WriteString(fmt.Sprintf(" Stage: %d files\n", stagedCount))
27-
s.WriteString(fmt.Sprintf(" Unstaged: %d files\n", unstagedCount))
25+
s.WriteString(styles.HeaderStyle.Render("  Git Status:") + "\n")
26+
s.WriteString(fmt.Sprintf("  Staged: %d files\n", stagedCount))
27+
s.WriteString(fmt.Sprintf("  Unstaged: %d files\n", unstagedCount))
28+
29+
if m.HasRemoteChanges {
30+
s.WriteString(styles.WarningStyle.Render("  New commits are available on the remote please pull\n"))
31+
}
2832
s.WriteString("\n")
2933
s.WriteString(styles.HeaderStyle.Render(" Modified files:") + "\n\n")
3034

0 commit comments

Comments
 (0)