Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
423 changes: 420 additions & 3 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ serde = "1.0.216"
serde_json = "1.0.133"
colored = "2.1.0"
git2 = "0.20.2"
webbrowser = "0.8"
jsonwebtoken = "9.3.1"

36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ in tags
```

Example output:

```
Showing the last 10 of 12 tags (from 2025-07-31 to 2025-07-31). Use --all to see all.

Expand All @@ -115,6 +116,41 @@ To view all tags, use the `--all` flag.
in tags --all
```

## Branch Operations

The `in br` command provides Git branch management functionality.

### Finish Branch

Finish the current branch by verifying it is already merged into the main branch and cleaning up:

```bash
in br finish
```

This command will:

- Check if the current branch is already merged into the main branch; abort if it is not
- Switch to the main branch
- Pull the latest changes
- Delete the feature branch
- Handle any uncommitted changes with stash if needed

### Open Remote Repository

Open the remote repository in your default browser:

```bash
in br open
```

This command will:

- Parse the `.git/config` file to find the remote origin URL
- Convert SSH/HTTPS Git URLs to web URLs
- For GitHub repositories, automatically navigate to the current branch
- Open the URL in your default browser

### License

MIT
29 changes: 25 additions & 4 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::jwt::InspectForJwt;
use argh::FromArgs;

#[derive(FromArgs, PartialEq, Debug)]
Expand All @@ -17,8 +18,9 @@ pub enum InspectionCommand {
ShowWorkingDirectory(InspectForWorkingDirectory),
ListFileSize(InspectForFileSize),
DirMark(InspectForDirMark),
FinishBranch(InspectForFinishBranch),
Branch(InspectForBranch),
ShowTags(InspectForTags),
Jwt(InspectForJwt),
}

/// command for inspecting IP addresses.
Expand Down Expand Up @@ -93,11 +95,30 @@ pub struct InspectForDirMark {
pub subcommand: DirMarkCommand,
}

// InspectForFinishBranch
/// command for branch operations
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "br")]
pub struct InspectForBranch {
#[argh(subcommand)]
pub subcommand: BranchCommand,
}

#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
pub enum BranchCommand {
Finish(InspectForBranchFinish),
Open(InspectForBranchOpen),
}

/// command for finishing a branch
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "finbr")]
pub struct InspectForFinishBranch {}
#[argh(subcommand, name = "finish")]
pub struct InspectForBranchFinish {}

/// command for opening remote repository
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "open")]
pub struct InspectForBranchOpen {}

#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
Expand Down
8 changes: 4 additions & 4 deletions src/dir_marks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl DirMarks {
.marks
.push(Bookmark::new(kwd.to_owned(), path.to_owned(), description.to_owned()));
}
println!("added `{}`\t{}\t{}", kwd, path, description)
println!("added `{kwd}`\t{path}\t{description}")
}

pub fn remove(&mut self, kwd: &str) {
Expand All @@ -91,7 +91,7 @@ impl DirMarks {
println!("removed `{}`\t{}\t{}", target.kwd, target.path, target.description);
self.marks.retain(|m| m.kwd != kwd);
} else {
println!("`{}` not found", kwd);
println!("`{kwd}` not found");
}
}

Expand All @@ -103,7 +103,7 @@ impl DirMarks {
pub fn jump(&mut self, kwd: &str) -> Result<(), String> {
// remove file in `JUMP_TARGET_DATA_PATH`` first
if std::path::Path::new(JUMP_TARGET_DATA_PATH).exists() {
std::fs::remove_file(JUMP_TARGET_DATA_PATH).map_err(|e| format!("failed to remove {}", e))?;
std::fs::remove_file(JUMP_TARGET_DATA_PATH).map_err(|e| format!("failed to remove {e}"))?;
}

// match by exact keyword
Expand Down Expand Up @@ -218,6 +218,6 @@ impl DirMarks {

/// print shell function for zsh
pub fn shell_fn() {
println!("{}", SHELL_FN_GG);
println!("{SHELL_FN_GG}");
}
}
Loading