diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..af329c2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + labels: + - 'maintenance' + groups: + actions: + patterns: + - '*' diff --git a/.github/workflows/deploy-wasm.yml b/.github/workflows/deploy-wasm.yml new file mode 100644 index 0000000..53df9d4 --- /dev/null +++ b/.github/workflows/deploy-wasm.yml @@ -0,0 +1,58 @@ +# Deploy WebAssembly cockle and terminal builds to github pages +name: Deploy wasm to github pages + +on: + push: + branches: + - main + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.14' + + - name: Install mamba + uses: mamba-org/setup-micromamba@v2 + with: + environment-file: wasm/wasm-environment.yml + cache-environment: true + + - name: Build the cockle and JupyterLite terminal deployments + shell: bash -l {0} + working-directory: wasm + run: | + cmake . + make + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./wasm/serve + + deploy: + needs: build + permissions: + pages: write + id-token: write + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8fe0ce6..6bd1a6c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 diff --git a/.gitignore b/.gitignore index e4f7ae8..9e99726 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build/ __pycache__/ .cache/ compile_commands.json +serve.log diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/CMakeLists.txt b/CMakeLists.txt index d18cbd9..36b401b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,14 +50,24 @@ set(GIT2CPP_SRC ${GIT2CPP_SOURCE_DIR}/subcommand/clone_subcommand.hpp ${GIT2CPP_SOURCE_DIR}/subcommand/commit_subcommand.cpp ${GIT2CPP_SOURCE_DIR}/subcommand/commit_subcommand.hpp + ${GIT2CPP_SOURCE_DIR}/subcommand/fetch_subcommand.cpp + ${GIT2CPP_SOURCE_DIR}/subcommand/fetch_subcommand.hpp ${GIT2CPP_SOURCE_DIR}/subcommand/init_subcommand.cpp ${GIT2CPP_SOURCE_DIR}/subcommand/init_subcommand.hpp ${GIT2CPP_SOURCE_DIR}/subcommand/log_subcommand.cpp ${GIT2CPP_SOURCE_DIR}/subcommand/log_subcommand.hpp ${GIT2CPP_SOURCE_DIR}/subcommand/merge_subcommand.cpp ${GIT2CPP_SOURCE_DIR}/subcommand/merge_subcommand.hpp + ${GIT2CPP_SOURCE_DIR}/subcommand/push_subcommand.cpp + ${GIT2CPP_SOURCE_DIR}/subcommand/push_subcommand.hpp + ${GIT2CPP_SOURCE_DIR}/subcommand/remote_subcommand.cpp + ${GIT2CPP_SOURCE_DIR}/subcommand/remote_subcommand.hpp ${GIT2CPP_SOURCE_DIR}/subcommand/reset_subcommand.cpp ${GIT2CPP_SOURCE_DIR}/subcommand/reset_subcommand.hpp + ${GIT2CPP_SOURCE_DIR}/subcommand/revlist_subcommand.cpp + ${GIT2CPP_SOURCE_DIR}/subcommand/revlist_subcommand.hpp + ${GIT2CPP_SOURCE_DIR}/subcommand/revparse_subcommand.cpp + ${GIT2CPP_SOURCE_DIR}/subcommand/revparse_subcommand.hpp ${GIT2CPP_SOURCE_DIR}/subcommand/status_subcommand.cpp ${GIT2CPP_SOURCE_DIR}/subcommand/status_subcommand.hpp ${GIT2CPP_SOURCE_DIR}/utils/ansi_code.cpp @@ -68,6 +78,8 @@ set(GIT2CPP_SRC ${GIT2CPP_SOURCE_DIR}/utils/git_exception.hpp ${GIT2CPP_SOURCE_DIR}/utils/output.cpp ${GIT2CPP_SOURCE_DIR}/utils/output.hpp + ${GIT2CPP_SOURCE_DIR}/utils/progress.cpp + ${GIT2CPP_SOURCE_DIR}/utils/progress.hpp ${GIT2CPP_SOURCE_DIR}/utils/terminal_pager.cpp ${GIT2CPP_SOURCE_DIR}/utils/terminal_pager.hpp ${GIT2CPP_SOURCE_DIR}/wrapper/annotated_commit_wrapper.cpp @@ -82,8 +94,12 @@ set(GIT2CPP_SRC ${GIT2CPP_SOURCE_DIR}/wrapper/object_wrapper.hpp ${GIT2CPP_SOURCE_DIR}/wrapper/refs_wrapper.cpp ${GIT2CPP_SOURCE_DIR}/wrapper/refs_wrapper.hpp + ${GIT2CPP_SOURCE_DIR}/wrapper/remote_wrapper.cpp + ${GIT2CPP_SOURCE_DIR}/wrapper/remote_wrapper.hpp ${GIT2CPP_SOURCE_DIR}/wrapper/repository_wrapper.cpp ${GIT2CPP_SOURCE_DIR}/wrapper/repository_wrapper.hpp + ${GIT2CPP_SOURCE_DIR}/wrapper/revwalk_wrapper.cpp + ${GIT2CPP_SOURCE_DIR}/wrapper/revwalk_wrapper.hpp ${GIT2CPP_SOURCE_DIR}/wrapper/signature_wrapper.cpp ${GIT2CPP_SOURCE_DIR}/wrapper/signature_wrapper.hpp ${GIT2CPP_SOURCE_DIR}/wrapper/status_wrapper.cpp diff --git a/README.md b/README.md index 64c6743..b9cc19f 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,16 @@ The CLI is tested using `python`. From the top-level directory: ```bash pytest -v ``` + +# WebAssembly build and deployment + +The `wasm` directory contains everything needed to build the local `git2cpp` source code as an +WebAssembly [Emscripten-forge](https://emscripten-forge.org/) package, create local +[cockle](https://github.com/jupyterlite/cockle) and +[JupyterLite terminal](https://github.com/jupyterlite/terminal) deployments that run in a browser, +and test the WebAssembly build. + +See the `README.md` in the `wasm` directory for further details. + +The latest `cockle` and JupyterLite `terminal` deployments using `git2cpp` are available at +[https://quantstack.net/git2cpp](https://quantstack.net/git2cpp) diff --git a/src/main.cpp b/src/main.cpp index e8479c8..9a3012b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,11 +10,16 @@ #include "subcommand/checkout_subcommand.hpp" #include "subcommand/clone_subcommand.hpp" #include "subcommand/commit_subcommand.hpp" +#include "subcommand/fetch_subcommand.hpp" #include "subcommand/init_subcommand.hpp" #include "subcommand/log_subcommand.hpp" #include "subcommand/merge_subcommand.hpp" +#include "subcommand/push_subcommand.hpp" +#include "subcommand/remote_subcommand.hpp" #include "subcommand/reset_subcommand.hpp" #include "subcommand/status_subcommand.hpp" +#include "subcommand/revparse_subcommand.hpp" +#include "subcommand/revlist_subcommand.hpp" int main(int argc, char** argv) { @@ -35,9 +40,14 @@ int main(int argc, char** argv) checkout_subcommand checkout(lg2_obj, app); clone_subcommand clone(lg2_obj, app); commit_subcommand commit(lg2_obj, app); + fetch_subcommand fetch(lg2_obj, app); reset_subcommand reset(lg2_obj, app); log_subcommand log(lg2_obj, app); merge_subcommand merge(lg2_obj, app); + push_subcommand push(lg2_obj, app); + remote_subcommand remote(lg2_obj, app); + revparse_subcommand revparse(lg2_obj, app); + revlist_subcommand revlist(lg2_obj, app); app.require_subcommand(/* min */ 0, /* max */ 1); diff --git a/src/subcommand/branch_subcommand.cpp b/src/subcommand/branch_subcommand.cpp index c321fa8..82decf1 100644 --- a/src/subcommand/branch_subcommand.cpp +++ b/src/subcommand/branch_subcommand.cpp @@ -39,7 +39,7 @@ void branch_subcommand::run() void branch_subcommand::run_list(const repository_wrapper& repo) { - auto head_name = repo.head().short_name(); + auto head_name = repo.head_short_name(); git_branch_t type = m_all_flag ? GIT_BRANCH_ALL : (m_remote_flag ? GIT_BRANCH_REMOTE : GIT_BRANCH_LOCAL); auto iter = repo.iterate_branches(type); auto br = iter.next(); diff --git a/src/subcommand/clone_subcommand.cpp b/src/subcommand/clone_subcommand.cpp index 6c9b803..acc6f14 100644 --- a/src/subcommand/clone_subcommand.cpp +++ b/src/subcommand/clone_subcommand.cpp @@ -2,6 +2,7 @@ #include "../subcommand/clone_subcommand.hpp" #include "../utils/output.hpp" +#include "../utils/progress.hpp" #include "../wrapper/repository_wrapper.hpp" clone_subcommand::clone_subcommand(const libgit2_object&, CLI::App& app) @@ -10,83 +11,30 @@ clone_subcommand::clone_subcommand(const libgit2_object&, CLI::App& app) sub->add_option("", m_repository, "The (possibly remote) repository to clone from.")->required(); sub->add_option("", m_directory, "The name of a new directory to clone into."); + sub->add_option("--depth", m_depth, "Create a shallow clone of that depth."); + // sub->add_option("--shallow-since", m_shallow_since, "