我正在尝试使用官方 GitHub 缓存操作(https://github.com/actions/cache)来缓存一些二进制文件以加快我的一些工作流程,但是在指定多个时我无法让它工作缓存路径。
这是我使用单个缓存路径设置的一个简单的工作测试:有一个用于写入缓存的操作,一个用于读取缓存的操作(两者都在单独的工作流程中执行,但在同一存储库和分支上)。首先执行写入操作,并创建一个文件“subdir/a.txt”,然后使用“actions/cache@v2”操作对其进行缓存:
# Test with single path
- name: Create file
shell: bash
run: |
mkdir subdir
cd subdir
printf '%s' "Lorem ipsum" >> a.txt
- name: Write cache (Single path)
uses: actions/cache@v2
with:
path: "D:/a/cache_test/cache_test/**/*.txt"
key: test-cache-single-path
Run Code Online (Sandbox Code Playgroud)
读取操作检索缓存,递归打印目录中所有文件的列表,以确认已从缓存中恢复文件,然后打印缓存的 txt 文件的内容:
- name: Get cached file
uses: actions/cache@v2
id: get-cache
with:
path: "D:/a/cache_test/cache_test/**/*.txt"
key: test-cache-single-path
- name: Print files
shell: bash
run: |
echo "Cache hit: ${{steps.get-cache.outputs.cache-hit}}"
cd "D:/a/cache_test/cache_test"
ls -R
cat "D:/a/cache_test/cache_test/subdir/a.txt"
Run Code Online (Sandbox Code Playgroud)
这可以正常工作,没有任何问题。
现在,缓存操作的描述包含指定多个缓存路径的示例:
- …Run Code Online (Sandbox Code Playgroud) 我需要一个函数将角度(以度为单位)限制在任意范围内[min,max]。这里有些例子:

彩色区域代表有效角度范围。
这是我到目前为止所拥有的:
static float clamp_angle(float ang,float min,float max)
{
ang = normalize_angle(ang); // normalize_angle transforms angle into [-180,180) range
min = normalize_angle(min);
max = normalize_angle(max);
if(angle_in_range(ang,min,max) == false)
{
if(abs(get_angle_difference(ang,min)) < abs(get_angle_difference(ang,max))
ang = min; // Clamp to min if we're closer to min than max
else
ang = max;
}
return ang;
}
Run Code Online (Sandbox Code Playgroud)
我缺少的是函数angle_in_range …
使用这个 git 命令,我可以获得远程存储库的所有可用标签,而无需克隆它:
git ls-remote --tags https://github.com/blender/blender.git
Run Code Online (Sandbox Code Playgroud)
我想使用 来复制这个libgit2。
我可以使用git_tag_list(https://libgit2.org/libgit2/#HEAD/group/tag/git_tag_list)来获取标签列表,但它需要一个git_repository对象。我可以用来git_repository_open创建一个git_repository对象,但只有当存储库已被克隆并存在于磁盘本地时才有效。我似乎找不到任何git_repository使用远程存储库 URL 创建对象的方法。
libgit2 示例有该命令的实现ls-remote,因此它一定是可能的:
git ls-remote --tags https://github.com/blender/blender.git
Run Code Online (Sandbox Code Playgroud)
不幸的是这个命令还需要一个git_repository对象,所以我有点不知所措。目前如果不先克隆就不可能实现吗?
我有一个带有以下声明的类:
\n\nclass IcoSphere\n{\n[...]\nprivate:\n int _addVertex(const glm::vec3 &p);\n int addVertex(glm::vec3 p);\n int addVertex(const glm::vec3 &&p);\n[...]\n};\nRun Code Online (Sandbox Code Playgroud)\n\n然后,我像这样调用“addVertex”:
\n\nIcoSphere sphere;\ndouble t = (1.0 +sqrt(5.0)) /2.0;\nsphere.addVertex(glm::vec3(-1,t,0));\nRun Code Online (Sandbox Code Playgroud)\n\n“addVertex”的参数显然不是引用,但 g++ 编译器会抛出以下错误:
\n\n./network/icosphere.cpp: In static member function \xe2\x80\x98static void IcoSphere::Create(glm::vec3&, float, std::vector<glm::tvec3<float, (glm::precision)0u> >&, int)\xe2\x80\x99:\n./network/icosphere.cpp:46:36: error: call of overloaded \xe2\x80\x98addVertex(glm::vec3)\xe2\x80\x99 is ambiguous\n sphere.addVertex(glm::vec3(-1,t,0));\n ^\n./network/icosphere.cpp:46:36: note: candidates are:\n./network/icosphere.cpp:19:5: note: int IcoSphere::addVertex(glm::vec3)\n int IcoSphere::addVertex(glm::vec3 p) {_addVertex(p);}\n ^\n./network/icosphere.cpp:20:5: note: int IcoSphere::addVertex(const vec3&&)\n int IcoSphere::addVertex(const glm::vec3 &&p) {_addVertex(p);}\n ^\nRun Code Online (Sandbox Code Playgroud)\n\n这对我来说没有多大意义,为什么它认为这是一个不明确的调用?
\n