Skip to content

Commit 8fbad40

Browse files
authored
Merge pull request #151 from neel1996/v2.1.1
# Bug fixes #148 - UI error in file view section #149 - Push to remote option disabled for new local branch #150 - Delay on loading branches in repository
2 parents 144f95f + f264ec6 commit 8fbad40

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2574
-1925
lines changed

.github/workflows/main.yml

Lines changed: 168 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,192 @@
11
name: Gitconvex build deploy
22

3-
on:
4-
push:
5-
branches: [ v2.0.1 ]
3+
on: push
64

75
jobs:
8-
build:
6+
libgit2-setup-test:
7+
name: Setup Libgit2 with Homebrew
98
runs-on: ubuntu-latest
10-
timeout-minutes: 60
119
steps:
12-
10+
- name: Install libssh2 and libgit2
11+
run: |
12+
brew install libssh2
13+
brew install libgit2
14+
15+
gitconvex-test:
16+
needs: libgit2-setup-test
17+
name: Gitconvex server test
18+
runs-on: ubuntu-latest
19+
env:
20+
PKG_CONFIG_PATH: /home/linuxbrew/.linuxbrew/Cellar/libgit2/1.1.0/lib/pkgconfig/
21+
22+
steps:
23+
- name: Install libgit2 from Homebrew
24+
run: |
25+
brew install libssh2
26+
brew install libgit2
27+
1328
- name: Set up Go 1.x
1429
uses: actions/setup-go@v2
1530
with:
16-
go-version: ^1.13
31+
go-version: ^1.16
1732
id: go
1833

1934
- name: Check out code into the Go module directory
2035
uses: actions/checkout@v2
2136

37+
- name: Run Go Test
38+
run: |
39+
sudo cp /home/linuxbrew/.linuxbrew/Cellar/libgit2/1.1.0/lib/lib* /usr/lib
40+
export PATH="/home/linuxbrew/.linuxbrew/Cellar/libgit2/1.1.0/lib/:$PATH"
41+
git config --global user.name "${{ secrets.USER_NAME }}" && git config --global user.email "${{ secrets.USER_EMAIL }}"
42+
export GOTESTENV=ci && go test -v ./...
43+
44+
# Build for Ubuntu Linux
45+
build-linux:
46+
needs: gitconvex-test
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Set up Go 1.x
50+
uses: actions/setup-go@v2
51+
with:
52+
go-version: ^1.16
53+
id: go
54+
55+
- name: Check out code into the Go module directory
56+
uses: actions/checkout@v2
57+
58+
- name: Setup libgit2
59+
run: |
60+
wget https://github.com/libgit2/libgit2/releases/download/v1.1.0/libgit2-1.1.0.tar.gz
61+
tar -xzf libgit2-1.1.0.tar.gz
62+
cd libgit2-1.1.0
63+
mkdir build && cd ./build
64+
sudo apt-get install libssl-dev
65+
cmake ..
66+
cmake --build .
67+
sudo make install
68+
sudo /sbin/ldconfig -v
69+
2270
- name: Get dependencies
2371
run: |
24-
go get -v -t -d ./...
25-
72+
go get gotest.tools/gotestsum
73+
go get -v ./...
74+
2675
- name: Clone test repo
2776
run: |
28-
mkdir -p /home/runner/work/gitconvex-server/starfleet/
77+
mkdir -p /home/runner/work/gitconvex/starfleet/
2978
git clone https://github.com/neel1996/starfleet.git /home/runner/work/gitconvex-server/starfleet/
30-
79+
3180
- name: Overwrite mock test file
3281
run: |
3382
echo "# gitconvex GoLang project" > /home/runner/work/gitconvex/gitconvex/README.md
34-
35-
- name: Run test cases
83+
84+
- name: Package gitconvex bundle
3685
run: |
37-
export GOTESTENV=ci && go test -v ./...
38-
39-
- name: Run sample build
86+
make build
87+
cd dist
88+
tar -czf gitconvex-linux-amd64-v${{ secrets.TARGET_RELEASE_CHANNEL }}.tar.gz *
89+
ls -ltr
90+
cd ..
91+
92+
- name: Github CLI release for Linux
93+
run: |
94+
gh version
95+
echo ${{ secrets.CLI_AUTH_KEY }} > auth.txt
96+
gh auth login --with-token < auth.txt
97+
gh release upload --repo ${{ secrets.USER_NAME }}/gitconvex ${{ secrets.TARGET_RELEASE_CHANNEL }} ./dist/gitconvex-linux-amd64-v${{ secrets.TARGET_RELEASE_CHANNEL }}.tar.gz --clobber
98+
99+
# Build for MacOS
100+
build-macos:
101+
needs: gitconvex-test
102+
runs-on: macos-latest
103+
steps:
104+
- name: Install brew
105+
run: |
106+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
107+
108+
- name: Set up Go 1.x
109+
uses: actions/setup-go@v2
110+
with:
111+
go-version: ^1.16
112+
id: go
113+
114+
- name: Check out code into the Go module directory
115+
uses: actions/checkout@v2
116+
117+
- name: Get dependencies
118+
run: |
119+
brew install libssh2
120+
brew install libgit2
121+
go get -v ./...
122+
123+
- name: Package gitconvex bundle
124+
run: |
125+
make build
126+
cd dist
127+
tar -czf gitconvex-macos-amd64-v${{ secrets.TARGET_RELEASE_CHANNEL }}.tar.gz *
128+
129+
- name: Github CLI Release for MacOS
130+
run: |
131+
echo ${{ secrets.CLI_AUTH_KEY }} > auth.txt
132+
gh auth login --with-token < auth.txt
133+
gh release upload ${{ secrets.TARGET_RELEASE_CHANNEL }} ./dist/gitconvex-macos-amd64-v${{ secrets.TARGET_RELEASE_CHANNEL }}.tar.gz --clobber
134+
135+
# Test Build for Windows
136+
build-windows:
137+
needs: gitconvex-test
138+
runs-on: windows-latest
139+
defaults:
140+
run:
141+
shell: bash
142+
steps:
143+
- name: Check out code into the Go module directory
144+
uses: actions/checkout@v2
145+
146+
- name: Add choco packages
147+
run: |
148+
choco install wget
149+
150+
- name: Check out code into the Go module directory
151+
uses: actions/checkout@v2
152+
153+
- name: Set up Go 1.x
154+
uses: actions/setup-go@v2
155+
with:
156+
go-version: ^1.16
157+
id: go
158+
159+
- name: Build libgit2 and gitconvex
160+
run: |
161+
unzip -q ./lib/win/dep_libs.zip
162+
wget -q https://github.com/libgit2/libgit2/releases/download/v1.1.0/libgit2-1.1.0.zip
163+
unzip -q libgit2-1.1.0.zip
164+
cd libgit2-1.1.0
165+
cp -rp ../lib/ .
166+
git clone https://github.com/libssh2/libssh2 libssh2
167+
mkdir build && mkdir install && cd build
168+
cmake -DPKG_CONFIG_EXECUTABLE=C:\\msys64\\usr\\bin\\pkg-config.exe -DCMAKE_INSTALL_PREFIX=../install -DOPENSSL_ROOT_DIR=../lib/win/ -DBUILD_CLAR=OFF -DEMBED_SSH_PATH=../libssh2 ..
169+
cmake --build . --target install
170+
cd ../install
171+
cp ./bin/git2.dll /c/msys64/usr/bin
172+
cp ./lib/git2.lib /c/msys64/usr/lib
173+
cp ./lib/pkgconfig/libgit2.pc /c/msys64/usr/lib/pkgconfig
174+
cp -r ./include/* /c/msys64/usr/include
175+
cd ../..
176+
rm C:\\Strawberry\\perl\\bin\\pkg-config.bat
177+
export PATH="/c/msys64/:/c/msys64/usr/:/c/msys64/usr/bin:$PATH"
178+
go get -v ./...
179+
./make.bat build
180+
181+
- name: Archive ZIP bundle for windows
182+
run: |
183+
cd dist
184+
cp -rp ../etc .
185+
7z a -r -tzip gitconvex-windows-v${{ secrets.TARGET_RELEASE_CHANNEL }}.zip *
186+
ls -ltr
187+
188+
- name: Github CLI Release for windows
40189
run: |
41-
go build -v
190+
echo ${{ secrets.CLI_AUTH_KEY }} > auth.txt
191+
gh auth login --with-token < auth.txt
192+
gh release upload ${{ secrets.TARGET_RELEASE_CHANNEL }} ./dist/gitconvex-windows-v${{ secrets.TARGET_RELEASE_CHANNEL }}.zip --clobber

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ build-server:
1515
mkdir -p ./dist
1616
go build -o ./dist
1717

18-
install_deps:
19-
if [[ "$(shell uname)" == "Darwin" ]]; then cd ./lib/macos_amd64 && ./install_deps && cd .. ; else cd ./lib/linux_x86_64 && ./install_deps && cd ..; fi
20-
2118
build:
2219
@echo "⚒️ Initiating gitconvex build"
2320
@echo "🗑️ Cleaning up old directories"
@@ -44,7 +41,6 @@ build:
4441
echo "Gitconvex build completed!" && \
4542
mv ./dist/gitconvex-server ./dist/gitconvex
4643
@echo "Installing libs"
47-
$(MAKE) install_deps
4844
@echo "✅ Gitconvex Build Completed successfully!"
4945
@echo "📬 Use ./dist/gitconvex to start Gitconvex on port 9001"
5046
@echo "📬 Try ./dist/gitconvex --port PORT_NUMBER to run gitconvex on the desired port"

git/git_remote_name.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

git/git_unpushed_commits.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
)
88

99
type UnPushedCommitInterface interface {
10-
UnPushedCommits() []*model.GitCommits
10+
UnPushedCommits() *model.UnPushedCommitResult
1111
}
1212

1313
type UnPushedCommitStruct struct {
1414
Repo *git2go.Repository
1515
RemoteRef string
16+
LocalRef string
1617
}
1718

1819
// commitModel function generates a pipe separated string with the required commit details
@@ -32,27 +33,40 @@ func commitModel(commit *git2go.Commit) *model.GitCommits {
3233
}
3334

3435
// UnPushedCommits compares the local branch and the remote branch to extract the commits which are not pushed to the remote
35-
func (u UnPushedCommitStruct) UnPushedCommits() []*model.GitCommits {
36+
func (u UnPushedCommitStruct) UnPushedCommits() *model.UnPushedCommitResult {
3637
repo := u.Repo
3738
remoteRef := u.RemoteRef
3839
var commitArray []*model.GitCommits
3940

4041
// Returning nil commit response if repo has no HEAD
4142
head, _ := repo.Head()
4243
if head == nil {
43-
return []*model.GitCommits{}
44+
logger.Log("HEAD is NULL", global.StatusError)
45+
return &model.UnPushedCommitResult{
46+
IsNewBranch: false,
47+
GitCommits: []*model.GitCommits{},
48+
}
4449
}
4550

4651
remoteBranch, remoteBranchErr := repo.LookupBranch(remoteRef, git2go.BranchRemote)
4752
if remoteBranchErr != nil {
4853
logger.Log(remoteBranchErr.Error(), global.StatusError)
49-
return commitArray
54+
logger.Log("Treating remote branch as a newly created branch", global.StatusWarning)
55+
56+
return &model.UnPushedCommitResult{
57+
IsNewBranch: true,
58+
GitCommits: nil,
59+
}
5060
}
5161

5262
// Checking if both branches have any varying commits
5363
diff := head.Cmp(remoteBranch.Reference)
5464
if diff == 0 {
55-
return commitArray
65+
logger.Log("No difference between remote and local branches", global.StatusError)
66+
return &model.UnPushedCommitResult{
67+
IsNewBranch: false,
68+
GitCommits: []*model.GitCommits{},
69+
}
5670
}
5771

5872
localCommit, _ := repo.LookupCommit(head.Target())
@@ -74,11 +88,17 @@ func (u UnPushedCommitStruct) UnPushedCommits() []*model.GitCommits {
7488
}
7589
} else {
7690
logger.Log("No new commits available to push", global.StatusWarning)
77-
return []*model.GitCommits{}
91+
return nil
92+
}
93+
return &model.UnPushedCommitResult{
94+
IsNewBranch: false,
95+
GitCommits: commitArray,
7896
}
79-
return commitArray
8097
} else {
8198
logger.Log("No new commits available to push", global.StatusWarning)
82-
return []*model.GitCommits{}
99+
return &model.UnPushedCommitResult{
100+
IsNewBranch: false,
101+
GitCommits: []*model.GitCommits{},
102+
}
83103
}
84104
}

global/current_version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package global
22

3-
var CurrentVersion = "2.1.0"
3+
var CurrentVersion = "2.1.1"
44

55
func GetCurrentVersion() string {
66
return CurrentVersion

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module github.com/neel1996/gitconvex-server
22

3-
go 1.15
3+
go 1.16
44

55
require (
66
github.com/99designs/gqlgen v0.13.0
77
github.com/TwinProduction/go-color v0.0.2
8-
github.com/go-git/go-git/v5 v5.2.0
98
github.com/google/uuid v1.1.2
109
github.com/gorilla/mux v1.8.0
11-
github.com/libgit2/git2go/v31 v31.4.12
10+
github.com/libgit2/git2go v0.28.4
11+
github.com/libgit2/git2go/v31 v31.4.10
1212
github.com/rs/cors v1.7.0
1313
github.com/stretchr/testify v1.4.0
1414
github.com/vektah/gqlparser/v2 v2.1.0

0 commit comments

Comments
 (0)