MCPcopy Create free account
hub / github.com/remotemobprogramming/mob / openLastModifiedFileIfPresent

Function openLastModifiedFileIfPresent

mob.go:672–710  ·  view source on GitHub ↗
(configuration config.Configuration)

Source from the content-addressed store, hash-verified

670}
671
672func openLastModifiedFileIfPresent(configuration config.Configuration) {
673 if !configuration.IsOpenCommandGiven() {
674 say.Debug("No open command given")
675 return
676 }
677
678 say.Debug("Try to open last modified file")
679 if !lastCommitIsWipCommit(configuration) {
680 say.Debug("Last commit isn't a WIP commit.")
681 return
682 }
683 lastCommitMessage := lastCommitMessage()
684 split := strings.Split(lastCommitMessage, "lastFile:")
685 if len(split) == 1 {
686 say.Warning("Couldn't find last modified file in commit message!")
687 return
688 }
689 if len(split) > 2 {
690 say.Warning("Could not determine last modified file from commit message, separator was used multiple times!")
691 return
692 }
693 lastModifiedFile := strings.Split(split[1], "\n")[0]
694 if strings.HasPrefix(lastModifiedFile, "\"") {
695 lastModifiedFile, _ = strconv.Unquote(lastModifiedFile)
696 }
697 if lastModifiedFile == "" {
698 say.Debug("Could not find last modified file in commit message")
699 return
700 }
701 lastModifiedFilePath := gitRootDir() + "/" + lastModifiedFile
702 commandname, args := openCommandFor(configuration, lastModifiedFilePath)
703 _, err := startCommand(commandname, args...)
704 if err != nil {
705 say.Warning(fmt.Sprintf("Couldn't open last modified file on your system (%s)", runtime.GOOS))
706 say.Warning(err.Error())
707 return
708 }
709 say.Debug("Open last modified file: " + lastModifiedFilePath)
710}
711
712func warnForActiveWipBranches(configuration config.Configuration, currentBaseBranch Branch) {
713 if isMobProgramming(configuration) {

Callers 1

startFunction · 0.85

Calls 8

DebugFunction · 0.92
WarningFunction · 0.92
lastCommitIsWipCommitFunction · 0.85
lastCommitMessageFunction · 0.85
gitRootDirFunction · 0.85
openCommandForFunction · 0.85
startCommandFunction · 0.85
IsOpenCommandGivenMethod · 0.80

Tested by

no test coverage detected