Documentation
¶
Index ¶
- Variables
- func Add(files []string) error
- func AddAll() error
- func AddRemote(url string) (string, error)
- func Branches() ([]string, error)
- func ClearAllConfig() error
- func ClearCredentials() error
- func ClearGlobalEmail() error
- func ClearGlobalName() error
- func Commit(message string) (string, error)
- func CreateBranch(name string) (string, error)
- func CurrentBranch() string
- func DeleteBranch(name string) (string, error)
- func GetCredentialHelper() string
- func GetRemotes() []string
- func GitignoreExists() bool
- func HasStoredCredentials() bool
- func Init(defaultBranch string) (string, error)
- func InitialCommit() (string, error)
- func IsGitRepo() bool
- func Pull() (string, error)
- func Push() (string, error)
- func SaveCredentialHelper() error
- func SetGlobalConfig(name, email string) error
- func ShortStatusLabel(code string) string
- func SwitchBranch(name string) (string, error)
- func WriteGitignore(content string) error
- type FileStatus
- type GitConfig
- type GitignoreTemplate
- type RepoStatus
Constants ¶
This section is empty.
Variables ¶
var GitignoreTemplates = []GitignoreTemplate{
{
Label: "Node.js / JavaScript",
Key: "node",
Content: `# Node.js
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnp/
.pnp.js
.yarn/
# Build
dist/
build/
.next/
out/
# Env
.env
.env.local
.env.*.local
# Logs
logs/
*.log
# OS
.DS_Store
Thumbs.db
`,
},
{
Label: "Python",
Key: "python",
Content: `# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
# Virtualenv
venv/
env/
ENV/
.venv/
# Build / dist
build/
dist/
*.egg-info/
.eggs/
# Env
.env
.env.local
# Jupyter
.ipynb_checkpoints
# mypy / pytest
.mypy_cache/
.pytest_cache/
.coverage
htmlcov/
# OS
.DS_Store
Thumbs.db
`,
},
{
Label: "Go",
Key: "go",
Content: `# Go
*.exe
*.exe~
*.dll
*.so
*.dylib
*.test
*.out
# Build output
/bin/
/dist/
# Vendor
/vendor/
# Env
.env
.env.local
# OS
.DS_Store
Thumbs.db
`,
},
{
Label: "Java / Kotlin",
Key: "java",
Content: `# Java / Kotlin
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
# Build
target/
build/
out/
.gradle/
.mvn/
# IDE
.idea/
*.iml
*.iws
*.ipr
.classpath
.project
.settings/
# OS
.DS_Store
Thumbs.db
`,
},
{
Label: "Rust",
Key: "rust",
Content: `# Rust
/target/
Cargo.lock
# Env
.env
.env.local
# OS
.DS_Store
Thumbs.db
`,
},
{
Label: "Flutter / Dart",
Key: "flutter",
Content: `# Flutter / Dart
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/
# Android
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/DerivedData/
**/ios/**/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Env
.env
.env.local
# OS
.DS_Store
Thumbs.db
`,
},
{
Label: "Generic / Other",
Key: "generic",
Content: `# Compiled and binaries
*.o
*.a
*.out
*.exe
*.dll
*.so
*.dylib
# Environments
.env
.env.local
.env.*.local
# Logs
*.log
logs/
# Build
dist/
build/
out/
# Dependencies
vendor/
node_modules/
# IDE / Editors
.idea/
.vscode/
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# OS
.DS_Store
Thumbs.db
desktop.ini
`,
},
}
Functions ¶
func ClearAllConfig ¶
func ClearAllConfig() error
ClearAllConfig removes name, email and credentials
func ClearCredentials ¶
func ClearCredentials() error
ClearCredentials removes stored credentials from the credential helper
func CreateBranch ¶
CreateBranch creates and switches to a new branch
func DeleteBranch ¶
DeleteBranch deletes a local branch
func GetCredentialHelper ¶
func GetCredentialHelper() string
GetCredentialHelper returns the current credential helper
func GitignoreExists ¶
func GitignoreExists() bool
GitignoreExists checks if .gitignore already exists
func HasStoredCredentials ¶
func HasStoredCredentials() bool
HasStoredCredentials checks if there are stored credentials
func InitialCommit ¶
InitialCommit stages everything and makes the first commit
func Push ¶
Push pushes to origin on the current branch — runs interactively so git can prompt for credentials
func SaveCredentialHelper ¶
func SaveCredentialHelper() error
SaveCredentialHelper enables git credential store so tokens are saved
func SetGlobalConfig ¶
SetGlobalConfig sets global git user name and email
func ShortStatusLabel ¶
ShortStatusLabel returns a human-readable label for a git status code
func WriteGitignore ¶
WriteGitignore creates a .gitignore file with the given content
Types ¶
type FileStatus ¶
type FileStatus struct {
Name string
Status string // "staged", "unstaged", "untracked"
Short string // git short status code (M, A, D, ?)
}
FileStatus represents a file in the working tree
type GitConfig ¶
GitConfig holds user configuration
func GetGlobalConfig ¶
func GetGlobalConfig() GitConfig
GetGlobalConfig reads the global git user config
type GitignoreTemplate ¶
func GetTemplate ¶
func GetTemplate(key string) *GitignoreTemplate
GetTemplate returns a template by key
type RepoStatus ¶
type RepoStatus struct {
Branch string
Staged []FileStatus
Unstaged []FileStatus
Untracked []FileStatus
IsRepo bool
}
RepoStatus holds the full status of the repo