Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
60fb872c
Commit
60fb872c
authored
Aug 14, 2017
by
David Turner
Committed by
Nick Thomas
Sep 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add GL_USERNAME
parent
3aef5f9a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
11 deletions
+18
-11
internal/api/api.go
internal/api/api.go
+4
-0
internal/git/archivereader.go
internal/git/archivereader.go
+1
-1
internal/git/blob.go
internal/git/blob.go
+2
-2
internal/git/command.go
internal/git/command.go
+8
-5
internal/git/diff.go
internal/git/diff.go
+1
-1
internal/git/format-patch.go
internal/git/format-patch.go
+1
-1
internal/git/git-http.go
internal/git/git-http.go
+1
-1
No files found.
internal/api/api.go
View file @
60fb872c
...
...
@@ -80,6 +80,10 @@ type Response struct {
// GL_ID is an environment variable used by gitlab-shell hooks during 'git
// push' and 'git pull'
GL_ID
string
// GL_USERNAME holds gitlab username of the user who is taking the action causing hooks to be invoked
GL_USERNAME
string
// GL_REPOSITORY is an environment variable used by gitlab-shell hooks during
// 'git push' and 'git pull'
GL_REPOSITORY
string
...
...
internal/git/archivereader.go
View file @
60fb872c
...
...
@@ -74,7 +74,7 @@ func newArchiveReader(ctx context.Context, repoPath string, format ArchiveFormat
a
=
&
archiveReader
{}
compressCmd
,
formatArg
:=
parseArchiveFormat
(
format
)
archiveCmd
:=
gitCommand
(
""
,
""
,
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
formatArg
,
"--prefix="
+
archivePrefix
+
"/"
,
commitId
)
archiveCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
repoPath
,
"archive"
,
"--format="
+
formatArg
,
"--prefix="
+
archivePrefix
+
"/"
,
commitId
)
var
archiveStdout
io
.
ReadCloser
archiveStdout
,
err
=
archiveCmd
.
StdoutPipe
()
...
...
internal/git/blob.go
View file @
60fb872c
...
...
@@ -52,13 +52,13 @@ func handleSendBlobWithGitaly(w http.ResponseWriter, r *http.Request, params *bl
func
handleSendBlobLocally
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
,
params
*
blobParams
)
{
log
.
Printf
(
"SendBlob: sending %q for %q"
,
params
.
BlobId
,
r
.
URL
.
Path
)
sizeOutput
,
err
:=
gitCommand
(
""
,
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"-s"
,
params
.
BlobId
)
.
Output
()
sizeOutput
,
err
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"-s"
,
params
.
BlobId
)
.
Output
()
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendBlob: get blob size: %v"
,
err
))
return
}
gitShowCmd
:=
gitCommand
(
""
,
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"blob"
,
params
.
BlobId
)
gitShowCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"cat-file"
,
"blob"
,
params
.
BlobId
)
stdout
,
err
:=
gitShowCmd
.
StdoutPipe
()
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendBlob: git cat-file stdout: %v"
,
err
))
...
...
internal/git/command.go
View file @
60fb872c
...
...
@@ -2,6 +2,7 @@ package git
import
(
"fmt"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/api"
"os"
"os/exec"
"syscall"
...
...
@@ -10,7 +11,7 @@ import (
var
execCommand
=
exec
.
Command
// Git subprocess helpers
func
gitCommand
(
glId
string
,
glRepository
string
,
name
string
,
args
...
string
)
*
exec
.
Cmd
{
func
gitCommand
Api
(
a
*
api
.
Response
,
name
string
,
args
...
string
)
*
exec
.
Cmd
{
cmd
:=
execCommand
(
name
,
args
...
)
// Start the command in its own process group (nice for signalling)
cmd
.
SysProcAttr
=
&
syscall
.
SysProcAttr
{
Setpgid
:
true
}
...
...
@@ -19,12 +20,14 @@ func gitCommand(glId string, glRepository string, name string, args ...string) *
fmt
.
Sprintf
(
"HOME=%s"
,
os
.
Getenv
(
"HOME"
)),
fmt
.
Sprintf
(
"PATH=%s"
,
os
.
Getenv
(
"PATH"
)),
fmt
.
Sprintf
(
"LD_LIBRARY_PATH=%s"
,
os
.
Getenv
(
"LD_LIBRARY_PATH"
)),
fmt
.
Sprintf
(
"GL_ID=%s"
,
glId
),
fmt
.
Sprintf
(
"GL_PROTOCOL=http"
),
}
if
glRepository
!=
""
{
cmd
.
Env
=
append
(
cmd
.
Env
,
fmt
.
Sprintf
(
"GL_REPOSITORY=%s"
,
glRepository
))
if
a
!=
nil
{
cmd
.
Env
=
append
(
cmd
.
Env
,
fmt
.
Sprintf
(
"GL_ID=%s"
,
a
.
GL_ID
))
cmd
.
Env
=
append
(
cmd
.
Env
,
fmt
.
Sprintf
(
"GL_USERNAME=%s"
,
a
.
GL_USERNAME
))
if
a
.
GL_REPOSITORY
!=
""
{
cmd
.
Env
=
append
(
cmd
.
Env
,
fmt
.
Sprintf
(
"GL_REPOSITORY=%s"
,
a
.
GL_REPOSITORY
))
}
}
// If we don't do something with cmd.Stderr, Git errors will be lost
cmd
.
Stderr
=
os
.
Stderr
...
...
internal/git/diff.go
View file @
60fb872c
...
...
@@ -28,7 +28,7 @@ func (d *diff) Inject(w http.ResponseWriter, r *http.Request, sendData string) {
log
.
Printf
(
"SendDiff: sending diff between %q and %q for %q"
,
params
.
ShaFrom
,
params
.
ShaTo
,
r
.
URL
.
Path
)
gitDiffCmd
:=
gitCommand
(
""
,
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"diff"
,
params
.
ShaFrom
,
params
.
ShaTo
)
gitDiffCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"diff"
,
params
.
ShaFrom
,
params
.
ShaTo
)
stdout
,
err
:=
gitDiffCmd
.
StdoutPipe
()
if
err
!=
nil
{
helper
.
Fail500
(
w
,
r
,
fmt
.
Errorf
(
"SendDiff: create stdout pipe: %v"
,
err
))
...
...
internal/git/format-patch.go
View file @
60fb872c
...
...
@@ -29,7 +29,7 @@ func (p *patch) Inject(w http.ResponseWriter, r *http.Request, sendData string)
log
.
Printf
(
"SendPatch: sending patch between %q and %q for %q"
,
params
.
ShaFrom
,
params
.
ShaTo
,
r
.
URL
.
Path
)
gitRange
:=
fmt
.
Sprintf
(
"%s..%s"
,
params
.
ShaFrom
,
params
.
ShaTo
)
gitPatchCmd
:=
gitCommand
(
""
,
""
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"format-patch"
,
gitRange
,
"--stdout"
)
gitPatchCmd
:=
gitCommand
Api
(
nil
,
"git"
,
"--git-dir="
+
params
.
RepoPath
,
"format-patch"
,
gitRange
,
"--stdout"
)
stdout
,
err
:=
gitPatchCmd
.
StdoutPipe
()
if
err
!=
nil
{
...
...
internal/git/git-http.go
View file @
60fb872c
...
...
@@ -79,7 +79,7 @@ func startGitCommand(a *api.Response, stdin io.Reader, stdout io.Writer, action
args
:=
[]
string
{
subCommand
(
action
),
"--stateless-rpc"
}
args
=
append
(
args
,
options
...
)
args
=
append
(
args
,
a
.
RepoPath
)
cmd
=
gitCommand
(
a
.
GL_ID
,
a
.
GL_REPOSITORY
,
"git"
,
args
...
)
cmd
=
gitCommand
Api
(
a
,
"git"
,
args
...
)
cmd
.
Stdin
=
stdin
cmd
.
Stdout
=
stdout
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment