chaoss / chaoss/CollectOSS

CLI should prevent adding duplicate repos

Open
#5 5 comments 0 reactions 0 assignees View on GitHub
CLI
Dominant language
Python
Stars
13
Forks
17
Avg merge
6h 59m
Merged PRs (30d)
1

Description

> [!NOTE]
> Migrated from [augurlabs/augur#1357](https://github.com/augurlabs/augur/issues/1357)
> Originally opened by `@jberkus` on 2021-07-16

---

Please help us help you by filling out the following sections as thoroughly as you can.

**Description:**

It is currently possible to add duplicate repo records using the CLI. Instead, a combination of database constraints and error-trapping should prevent duplicates being added.

**How to reproduce:**
1. Create a new augur database
2. Create a file with several repos in it
3. Add those repos using `augur db add-repos filename.csv`
4. Now, repeat that command
5. All of the repos will be added twice

**Expected behavior:**
The duplicate repos should not have been added, and I should have received terminal output notifying me of such.

Clearly, augur_data.repo ought to have a unique index either on (repo_git), or on (repo_group_id,repo_git) depending on whether or not we want the same repo to be allowed to appear in multiple groups. Then `add-repos` should look for and trap duplicate key errors and notify the user.

**Log files**

```
root@7d7b1b1332e1:/augur# augur db add-repos kvrep.csv
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/move2kube.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/pelorus.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-operator.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-controller.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-agnosticd.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/forklift-operator.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-ui.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/cpma.git` into repo group 101
...
root@7d7b1b1332e1:/augur# augur db add-repos kvrep.csv
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/move2kube.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/pelorus.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-operator.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-controller.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-agnosticd.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/forklift-operator.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/mig-ui.git` into repo group 101
CLI: [db.add_repos] [INFO] Inserting repo with Git URL `https://github.com/konveyor/cpma.git` into repo group 101

augur=# select repo_id, repo_group_id, repo_git from augur_data.repo order by repo_git;
repo_id | repo_group_id | repo_git
---------+---------------+--------------------------------------------------------------
1 | 1 | https://github.com/chaoss/augur.git
25461 | 101 | https://github.com/konveyor/bz-github-action.git
25531 | 101 | https://github.com/konveyor/bz-github-action.git
25472 | 101 | https://github.com/konveyor/community.git
25542 | 101 | https://github.com/konveyor/community.git
25533 | 101 | https://github.com/konveyor/controller.git
25463 | 101 | https://github.com/konveyor/controller.git
25437 | 101 | https://github.com/konveyor/cpma.git
25507 | 101 | https://github.com/konveyor/cpma.git
25553 | 101 | https://github.com/konveyor/crane.git
25483 | 101 | https://github.com/konveyor/crane.git
```

**Software versions:**
- Augur: 0.17.0
- OS: Container image from source

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.