Add git *after* members to record

pull/18/head
Simon Let 6 years ago
parent d4959cffbe
commit 7b437b6870
  1. 2
      VERSION
  2. 19
      cmd/collect/main.go
  3. 1
      cmd/daemon/main.go
  4. 11
      pkg/records/records.go
  5. 13
      scripts/shellrc.sh

@ -1 +1 @@
1.1.3
1.1.4

@ -75,9 +75,13 @@ func main() {
machtype := flag.String("machtype", "", "$MACHTYPE")
gitCdup := flag.String("gitCdup", "", "git rev-parse --show-cdup")
gitRemote := flag.String("gitRemote", "", "git remote get-url origin")
gitCdupAfter := flag.String("gitCdupAfter", "", "git rev-parse --show-cdup")
gitRemoteAfter := flag.String("gitRemoteAfter", "", "git remote get-url origin")
gitCdupExitCode := flag.Int("gitCdupExitCode", -1, "... $?")
gitRemoteExitCode := flag.Int("gitRemoteExitCode", -1, "... $?")
gitCdupExitCodeAfter := flag.Int("gitCdupExitCodeAfter", -1, "... $?")
gitRemoteExitCodeAfter := flag.Int("gitRemoteExitCodeAfter", -1, "... $?")
// before after
timezoneBefore := flag.String("timezoneBefore", "", "")
@ -161,6 +165,10 @@ func main() {
if *gitRemoteExitCode != 0 {
*gitRemote = ""
}
gitDirAfter, gitRealDirAfter := getGitDirs(*gitCdupAfter, *gitCdupExitCodeAfter, *pwd)
if *gitRemoteExitCodeAfter != 0 {
*gitRemoteAfter = ""
}
if *osReleaseID == "" {
*osReleaseID = "linux"
@ -219,10 +227,13 @@ func main() {
RealtimeSinceSessionStart: realtimeSinceSessionStart,
RealtimeSinceBoot: realtimeSinceBoot,
GitDir: gitDir,
GitRealDir: gitRealDir,
GitOriginRemote: *gitRemote,
MachineID: readFileContent(machineIDPath),
GitDir: gitDir,
GitRealDir: gitRealDir,
GitOriginRemote: *gitRemote,
GitDirAfter: gitDirAfter,
GitRealDirAfter: gitRealDirAfter,
GitOriginRemoteAfter: *gitRemoteAfter,
MachineID: readFileContent(machineIDPath),
OsReleaseID: *osReleaseID,
OsReleaseVersionID: *osReleaseVersionID,

@ -126,6 +126,7 @@ func (h *recordHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
func runServer(port int, outputPath string) {
http.HandleFunc("/status", statusHandler)
http.Handle("/record", &recordHandler{OutputPath: outputPath})
//http.Handle("/session_start", &recordHandler{OutputPath: outputPath})
http.ListenAndServe(":"+strconv.Itoa(port), nil)
}

@ -56,10 +56,13 @@ type BaseRecord struct {
RealtimeSinceBoot float64 `json:"realtimeSinceBoot"`
//Logs []string `json: "logs"`
GitDir string `json:"gitDir"`
GitRealDir string `json:"gitRealDir"`
GitOriginRemote string `json:"gitOriginRemote"`
MachineID string `json:"machineId"`
GitDir string `json:"gitDir"`
GitRealDir string `json:"gitRealDir"`
GitOriginRemote string `json:"gitOriginRemote"`
GitDirAfter string `json:"gitDirAfter"`
GitRealDirAfter string `json:"gitRealDirAfter"`
GitOriginRemoteAfter string `json:"gitOriginRemoteAfter"`
MachineID string `json:"machineId"`
OsReleaseID string `json:"osReleaseId"`
OsReleaseVersionID string `json:"osReleaseVersionId"`

@ -43,6 +43,10 @@ __resh_run_daemon() {
nohup resh-daemon &>/dev/null & disown
}
# __resh_session_init() {
# resh-event session_start --sessionId "$__RESH_SESSION_ID" --sessionPid "$__RESH_SESSION_PID"
# }
#
__resh_bash_completion_init() {
local bash_completion_dir=~/.resh/bash_completion.d
# source user completion directory definitions
@ -95,6 +99,7 @@ if [ -z "${__RESH_SESSION_ID+x}" ]; then
export __RESH_SESSION_ID; __RESH_SESSION_ID=$(__resh_get_uuid)
export __RESH_SESSION_PID="$$"
# TODO add sesson time
# __resh_session_init __RESH_SESSION_ID __RESH_SESSION_PID
fi
# posix
@ -178,6 +183,10 @@ __resh_precmd() {
__RESH_RT_AFTER=$(__resh_get_epochrealtime)
__RESH_TZ_AFTER=$(date +%z)
__RESH_PWD_AFTER="$PWD"
__RESH_GIT_CDUP_AFTER="$(git rev-parse --show-cdup 2>/dev/null)"
__RESH_GIT_CDUP_EXIT_CODE_AFTER=$?
__RESH_GIT_REMOTE_AFTER="$(git remote get-url origin 2>/dev/null)"
__RESH_GIT_REMOTE_EXIT_CODE_AFTER=$?
if [ -n "${__RESH_COLLECT}" ]; then
if [ "$__RESH_VERSION" != "$(resh-collect -version)" ]; then
# shellcheck source=shellrc.sh
@ -223,6 +232,10 @@ __resh_precmd() {
-gitCdupExitCode "$__RESH_GIT_CDUP_EXIT_CODE" \
-gitRemote "$__RESH_GIT_REMOTE" \
-gitRemoteExitCode "$__RESH_GIT_REMOTE_EXIT_CODE" \
-gitCdupAfter "$__RESH_GIT_CDUP_AFTER" \
-gitCdupExitCodeAfter "$__RESH_GIT_CDUP_EXIT_CODE_AFTER" \
-gitRemoteAfter "$__RESH_GIT_REMOTE_AFTER" \
-gitRemoteExitCodeAfter "$__RESH_GIT_REMOTE_EXIT_CODE_AFTER" \
-realtimeBefore "$__RESH_RT_BEFORE" \
-realtimeAfter "$__RESH_RT_AFTER" \
-realtimeSession "$__RESH_RT_SESSION" \

Loading…
Cancel
Save