mirror of
				https://github.com/cmderdev/cmder.git
				synced 2025-11-04 03:12:16 +08:00 
			
		
		
		
	add ability to disable git
This commit is contained in:
		
							
								
								
									
										21
									
								
								vendor/clink.lua
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/clink.lua
									
									
									
									
										vendored
									
									
								
							@@ -280,6 +280,24 @@ local function get_svn_status()
 | 
				
			|||||||
    return true
 | 
					    return true
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					-- Get the status of working dir
 | 
				
			||||||
 | 
					-- @return {bool}
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
 | 
					local function get_git_status_setting()
 | 
				
			||||||
 | 
					    gitStatusSetting = io.popen("git config cmder.status")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for line in gitStatusSetting:lines() do
 | 
				
			||||||
 | 
					        if string.match(line, 'false') then
 | 
				
			||||||
 | 
					          gitStatusSetting:close()
 | 
				
			||||||
 | 
					          return false
 | 
				
			||||||
 | 
					        end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    gitStatusSetting:close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return true
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function git_prompt_filter()
 | 
					local function git_prompt_filter()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- Colors for git status
 | 
					    -- Colors for git status
 | 
				
			||||||
@@ -290,6 +308,8 @@ local function git_prompt_filter()
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    local git_dir = get_git_dir()
 | 
					    local git_dir = get_git_dir()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if get_git_status_setting() then
 | 
				
			||||||
      if git_dir then
 | 
					      if git_dir then
 | 
				
			||||||
          -- if we're inside of git repo then try to detect current branch
 | 
					          -- if we're inside of git repo then try to detect current branch
 | 
				
			||||||
          local branch = get_git_branch(git_dir)
 | 
					          local branch = get_git_branch(git_dir)
 | 
				
			||||||
@@ -312,6 +332,7 @@ local function git_prompt_filter()
 | 
				
			|||||||
              return false
 | 
					              return false
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- No git present or not in git file
 | 
					    -- No git present or not in git file
 | 
				
			||||||
    clink.prompt.value = string.gsub(clink.prompt.value, "{git}", "")
 | 
					    clink.prompt.value = string.gsub(clink.prompt.value, "{git}", "")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user