-
-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#46 git import #78
#46 git import #78
Conversation
…ory by default instead of downloading the repository zip file
…t in place in future GitPython updates for the imports to work
…username and repository name, to prevent name clashes
…n with author renders it safe to change
…n with author renders it safe to change
crowd_anki/github/github_importer.py
Outdated
def download_and_import(self, repo): | ||
def download_and_import_git(self, github_repo): | ||
repo_parts = github_repo.split("/") | ||
repo_dir = Path(self.collection.media.dir()).joinpath("..", "CrowdAnkiGit", repo_parts[-1], "git") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the directory I think the ideal option would be to clone things into the place where snapshots go (it's available in config). The format there is snapshot_dir/<anki profile name>/<deck name>
Deck name is a bit tricky - if you follow the convention of naming the repo with the CrowdAnki deck name like here https://github.com/Stvad/Software_Engineering__git then you can use that, but I suspect you don't (being not a fun of those names & all :p)
So another option can be is storing the snapshot destination on per deck basis. Something like:
- If you're importing deck from git repo -> set snapshot destination to the original import directory
- If it's not set -> set it to the default one
- Use these names on snapshot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll admit that I didn't understand very well what you meant by the three bullet points above. Please see the commits I just pushed, and how they relate to what you suggest, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you had a chance to take a look? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to take a closer look today/tomorrow.
What the comment above was getting at that if the name of repository does not match the name of the deck - then initial import would work but subsequent snapshots will go to a different directory which is problematic. I proposed a way to solve that by changing how we determine the snapshot directory for deck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But the name of the repository does not determine the name of the deck: when importing from github, the deck name is taken from deck.json
So even if I import the "covid-19-anki-deck, the deck I see in Anki is "COVID-19" (in fact, I see "COVID-19_2", "COVID-19_3", etc, but right now that's beyond the point). Indeed, though, the name of the imported repository directory will be covid-19-anki-deck
, so I see your point.
Nevertheless, the user can rename the deck to something wildly different, and they can also move the cards in and out of it at will. Being driven by the deck name will lead to a multitude of issues.
The way it would make the most sense for me for all this to happen is if each deck had a property called remote_url
or something like that, which pointed to (either the original, or to the forked) remote repository. Then we'd use this property to determine the directory names for the repositories.
I'm not familiar enough with the Anki codebase to know whether that's something that could be implemented?
Integrating with github to create forks/etc - In general seems like a good idea for simplifying the flow, we should discuss how interaction would look like before going there though. And should be a separate CR. Also using the actual cli tool really makes life harder distribution-wise, I imagine there is python lib out there for talking to Github API, which would be a better choice |
agreed, a python library would be great for that. |
…will do, even local ones
crowd_anki/config/config_settings.py
Outdated
self.addon_manager = addon_manager or mw.addonManager | ||
self._config = init_values or addon_manager.getConfig(__name__) | ||
self._window = window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be initialized similar to the addon_manage
(i.e. be assigned mw
by default) also probably should be a more specific dependency - does pm
stands for something like profile_manager
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean like this? (see the latest commit)
Have you found developer.github.com/v3/libraries? It has a |
…d at the provided URL
…ng profile_manager
Thanks @katrinleinweber for researching the libraries. Can't wait to have this implemented. For now, let's finalize this pull request. |
@Stvad did you have a chance to take a look at the commits? Thanks. |
@evolverine I apologize for the delay, I thought I did, but I missed the latest batch. I'll take a look in the next few days! |
Looks good to me besides the small nit that I've noted! |
…lt in the repository being instantiated without a parent folder
great. And check out the last commit as well, where I made improvements in the way the repository URL is parsed. If that looks good, on my side it's all done (otherwise let me know if any changes are in order). |
crowd_anki/github/github_importer.py
Outdated
@@ -8,6 +8,16 @@ | |||
|
|||
BRANCH_NAME = "master" | |||
|
|||
|
|||
def get_repository_name(repository_url): | |||
repo_url_path = urlparse(repository_url).path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does using urlparse give us?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, not much. I thought it could help in cases when the URL contains query parameters, but nothing in github seems to.
crowd_anki/github/github_importer.py
Outdated
if repo_name.find(" ") != -1: | ||
raise ValueError("repository name in URL should not contain spaces") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's seems like an oddly specific thing to check for. should we just strip the string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took it out as well. I think the reason I was trying to validate the input so much was that Dulwich does create a folder and empty repository even when the URL is not correct, or does not contain a git repository. But we can handle that in other ways, perhaps.
…ameters. Also, checking for the space wasn't useful either; in that case, Dulwich will report an error Signed-off-by: Mihai Chira <mihai.chira@gmail.com>
Heya, did you have a chance to look at the latest changes? Thanks! |
Hey, thank you for a reminder, been a bit swamped recently =. Will take a look today |
Looks good! Thank you for working on this! Sorry for a slow turn-around |
Yaay! Calls for a celebration 😃️🎉️ |
A few notes:
Also, two questions: