Skip to content
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

make git optional #97

Open
hellodword opened this issue Aug 3, 2024 · 3 comments
Open

make git optional #97

hellodword opened this issue Aug 3, 2024 · 3 comments

Comments

@hellodword
Copy link
Contributor

hellodword commented Aug 3, 2024

Using git during the generate process assumes certain prerequisites, like having git installed and setting global user.name and user.email. However, I prefer not to set global git user.name and user.email, opting instead to set them per project, which results in an error during generation:

cli/generate.go

Line 145 in 0a713d1

if err := runCmdInDir(dir, "git", "commit", "-am", "init: extism"); err != nil {

Furthermore, based on the code, git is primarily used for cloning, which is not essential.

There's a submodule in https://github.com/extism/c-pdk-template

How about using go-git?

I'm trying to develop an extension system with this project. I aim to assume that the users creating extensions have as few relevant skills as possible, which is one reason why untrusted code is an issue, isn't it?

root@f616081b980c:/tmp# mkdir proj1
root@f616081b980c:/tmp# cd proj1/
root@f616081b980c:/tmp/proj1# git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /tmp/proj1/.git/
root@f616081b980c:/tmp/proj1# git config user.name "Your Name"
root@f616081b980c:/tmp/proj1# git config user.email "[email protected]"
root@f616081b980c:/tmp/proj1# git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
user.name=Your Name
[email protected]


root@f616081b980c:/tmp/proj1# extism -v gen plugin -l Go -o plugin
Cloning into 'plugin'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (8/8), done.
Receiving objects: 100% (9/9), done.
remote: Total 9 (delta 0), reused 5 (delta 0), pack-reused 0
Switched to a new branch 'extism-init'
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@f616081b980c.(none)')
Error: exit status 128
@G4Vi
Copy link
Contributor

G4Vi commented Aug 3, 2024

I also often avoid setting user.email and user.name globally. Maybe we can have it skip those git steps if those aren't configured and/or provide an option that enables/disables the git generation?

I'm undecided on whether using a library for git or scripting the cli is better, I'm curious how much it saves on binary size not having it. The cli interface for git appears to be pretty stable and avoids having a possible version conflict between the library and what the user uses on their system. If we stick with scripting the cli as a minimum we should have a proper error message if git isn't installed.

I will bring up both issues with the team.

@hellodword
Copy link
Contributor Author

binary size

I just submitted a PR for that #98

whether using a library for git or scripting the cli is better

Personally, I prefer not using any git if there's no submodule in the c-pdk-template.

I think the npm init style is pretty cool as it allows customizing the project name, version, license, etc., while extism gen plugin -l Go retains the go mod name, which I would like to change.

@G4Vi
Copy link
Contributor

G4Vi commented Aug 5, 2024

I discussed with the team and for the general case we want to keep the git initialization of new projects. However, we'd accept a change adding in a flag to disable it or possibly set the git info to use. Otherwise, it's also an option to avoid using the extism cli and use the template repos without it.

On git downloading, we'd accept a change to switch to go-git assuming it has compatibility with all git features we need and it portable. If any of the downloading can be done without git, we'd also accept a change that used another download method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants