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
63 changes: 8 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ Track individual files with precision, group them seamlessly, and commit or reve
<img src="./assets/qwe-diagram.png" alt="qwe diagram Logo">
</div>

A key design choice in qwe is the persistence of file-level tracking, even within a group. This gives you unparalleled flexibility.

Example: Imagine you are tracking files A, B, and C in a group called "Feature-A." You still have the freedom to commit an independent revision for file A alone without affecting the group's snapshot history for B and C.

This means you can:

- Maintain a clean, unified history for all files in the group (the Group Snapshot).
- Still perform granular, single-file rollbacks or commits outside the group's scope.

This approach ensures that qwe remains the flexible, non-intrusive file revision system that you can rely on.

## Installation

You can install **qwe** in two ways:
Expand All @@ -57,62 +46,26 @@ Make sure your Go environment’s `GOPATH/bin` is added to your system `PATH`.
### 2️⃣ Using Prebuilt Executables
Download the prebuilt binary for your platform from the **[Releases](https://github.com/mainak55512/qwe/releases)** section of this repository and add it to your PATH.


## Commands

| Command | Description |
|----------|-------------|
| `qwe` | Shows all the available commands |
| `qwe init` | Initialize qwe in the current directory |
| `qwe group-init <group name>` | Initialize a group in the current directory |
| `qwe groups` | List all the groups tracked in the repository |
| `qwe track <file-path>` | Start tracking a file |
| `qwe group-track <group name> <file-path>` | Start tracking a file in a group |
| `qwe list <file-path>` | List all commits for the specified file |
| `qwe group-list <group name>` | List all commits for the specified group |
| `qwe commit <file-path> "<commit message>"` | Commit changes to the file with a message |
| `qwe group-commit <group name> "<commit message>"` | Commit changes of all the files tracked in the group with a message |
| `qwe revert <file-path>` | Revert the file to the last committed version |
| `qwe revert <file-path> <commit-id>` | Revert the file to a previous version |
| `qwe group-revert <group name> <commit-id>` | Revert the files tracked in the group to a previous version |
| `qwe current <file-path>` | Shows current commit details of the specified file |
| `qwe group-current <file-path>` | Shows current commit details of the specified group |
| `qwe rebase <file-path>` | Revert file to its base version |
| `qwe diff <file-path>` | Shows latest uncommitted and last committed version diff |
| `qwe diff <file-path> <commit_id_1> <commit_id_2>` | Shows version diff of commit_id_1 & commit_id_2|
| `qwe diff <file-path> uncommitted <commit_id>` | Shows version diff of latest uncommitted version and commit_id version|


## Example Usage

*Tracking single file*
```bash
qwe init
qwe track notes.txt
qwe commit notes.txt "Initial notes added" // -> commitID 0
qwe commit notes.txt "Updated with new ideas" // -> commitID 1
qwe commit notes.txt "Removed already executed ideas" // -> commitID 2
qwe list notes.txt
qwe revert notes.txt 1
qwe current notes.txt
qwe diff notes.txt
qwe rebase notes.txt
```

*Tracking a group*
```bash
qwe init
qwe revert notes.txt 0
qwe group-init new_group
qwe group-track new_group notes.txt
qwe group-track new_group example.txt
qwe group-track new_group README.md
qwe group-commit new_group "Initial commit" // -> commitID 0
qwe group-commit new_group "Updated commit" // -> commitID 1
qwe group-list new_group
qwe group-revert new_group 0
qwe group-current new_group
qwe group-commit new_group "Initial commit" // -> commitID 1
qwe group-commit new_group "Updated commit" // -> commitID 2
qwe group-revert new_group 0 // -> Revert back to base version (to the version from which group tracking started)
```

## Documentation

Full documentation is available at [https://mainak55512.github.io/qwe](https://mainak55512.github.io/qwe/).

## Why qwe?

- Ideal for **independent file tracking** without setting up a full Git repo.
Expand Down
17 changes: 14 additions & 3 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func helpText() {
fmt.Fprintln(w, "qwe group-revert <group name> <commit-id>\t[Revert all the files tracked in the group to a previous version]")
fmt.Fprintln(w, "qwe current <file-path>\t[Get current commit details of the file]")
fmt.Fprintln(w, "qwe group-current <group name>\t[Get current commit details of the group]")
fmt.Fprintln(w, "qwe group-current <group name> <commit-id>\t[Get commit details of a specific commit of the group]")
fmt.Fprintln(w, "qwe recover <file-path>\t[Restore deleted file if earlier tracked]")
fmt.Fprintln(w, "qwe rebase <file-path>\t[Revert back to base version of the file]")
fmt.Fprintln(w, "qwe diff <file-path>\t[Shows difference between latest uncommitted version and latest committed version]")
Expand Down Expand Up @@ -243,11 +244,21 @@ func HandleArgs() error {
}
case "group-current":
{
if len(command_list) != 2 {
if len(command_list) != 2 && len(command_list) != 3 {
return er.CLIGrpCurrentErr
}
if err := cm.CurrentGroupCommit(command_list[1]); err != nil {
return err
if len(command_list) == 2 {
if err := cm.GroupCommitDetails(command_list[1], -1); err != nil {
return err
}
} else if len(command_list) == 3 {
commitNumber, err := strconv.Atoi(command_list[2])
if err != nil {
return er.InvalidCommitNo
}
if err := cm.GroupCommitDetails(command_list[1], commitNumber); err != nil {
return err
}
}
}
case "recover":
Expand Down
23 changes: 18 additions & 5 deletions commit/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func CurrentCommit(filePath string) error {
}

// Prints current group commit details
func CurrentGroupCommit(groupName string) error {
func GroupCommitDetails(groupName string, commitNumber int) error {

// Get group tracker
_, groupTracker, err := tr.GetTracker(1)
Expand All @@ -325,10 +325,23 @@ func CurrentGroupCommit(groupName string) error {
return er.InvalidGroup
}

// Get the commit id of current version from the group tracker
// Get the commit id of specific version from the group tracker
var commitID int

// stores commit UID
var commit string

if commitNumber == -1 {
commit = val.Current
} else {
if commitNumber > len(val.VersionOrder)-1 {
return er.InvalidCommitNo
}
commit = val.VersionOrder[commitNumber]
}

for i, e := range val.VersionOrder {
if e == val.Current {
if e == commit {
commitID = i
break
}
Expand All @@ -337,8 +350,8 @@ func CurrentGroupCommit(groupName string) error {
// Print current commit details
w := new(tw.Writer)
w.Init(os.Stdout, 0, 0, 0, ' ', tw.TabIndent)
fmt.Fprintf(w, "\nName:\t %s\nCurrent Commit ID:\t %d\nCommit Message:\t %s\n", val.GroupName, commitID, val.Versions[val.Current].CommitMessage)
files := val.Versions[val.Current].Files
fmt.Fprintf(w, "\nName:\t %s\nCurrent Commit ID:\t %d\nCommit Message:\t %s\n", val.GroupName, commitID, val.Versions[commit].CommitMessage)
files := val.Versions[commit].Files
fmt.Fprintf(w, "\nAssociated files:\n")
for e := range files {
fmt.Fprintf(w, "File: %s, \tCommitID: %d\n", files[e].FileName, files[e].CommitNumber)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added docs/.cache/plugin/social/fonts/Roboto/Black.ttf
Binary file not shown.
Binary file not shown.
Binary file added docs/.cache/plugin/social/fonts/Roboto/Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/.cache/plugin/social/fonts/Roboto/Light.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added docs/.cache/plugin/social/fonts/Roboto/Thin.ttf
Binary file not shown.
Loading