小编Hug*_*ugo的帖子

从 PowerShell 脚本中提取时出错

我有一个简单的 PowerShell 脚本来使文件夹与其 git 存储库保持同步。

Param(
    [Parameter(Mandatory = $true)][string]$branch,
    [string]$location,
    [int]$depth
)

Get-ChildItem -Recurse -Directory -Depth $depth -Filter _$branch -Name -Path $location | 
ForEach-Object {
    Write-Output "`n$("{0:MM/dd/yy} {0:HH:mm:ss}" -f (Get-Date)): Getting latest from $location$_"
    git -C $location$_ pull
} *>> logs\$branch.log
Run Code Online (Sandbox Code Playgroud)

当存储库已经是最新的时,它可以正常工作。但是,如果不是,则输出如下:

07/29/19 14:47:27:从某个路径获取最新信息
git :来自 https://gitlab.com/someplace
在某个地方\UpdateBranch.ps1:10 字符:5
+ git -C $location$_ 拉
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (来自 https://gi...n/somerepo:String) [], RemoteException
    + FullQualifiedErrorId : NativeCommandError

   b34e5d0..3ec9561 开发 -> 起源/开发
   b6d33b1..65fb520 功能/功能 1 -> 原点/功能/功能 1
 * [新分支] …

git powershell

3
推荐指数
1
解决办法
1361
查看次数

在 ReactJS 中的 Spotify API 上为 PKCE 身份验证创建代码验证器和挑战

我正在尝试按照他们的 api 文档将 Spotify auth 添加到我的单页反应应用程序中。

到目前为止,这是我根据我在网上找到的解决方案生成代码的方式:

const generateVerifier = () => {
    return crypto.randomBytes(64).toString('hex');
}

const getChallenge = verifier => {
    return crypto.createHash('sha256')
        .update(verifier)
        .digest('base64')
        .replace(/\+/g, '-')
        .replace(/\//g, '_')
        .replace(/=/g, '')
}
Run Code Online (Sandbox Code Playgroud)

我使用该技术创建的一对代码示例:

  • 验证者: e8c3745e93a9c25ce5c2653ee36f5b4fa010b4f4df8dfbad7055f4d88551dd960fb5b7602cdfa61088951eac36429862946e86d20b15250a8f0159f1ad001605
  • 挑战: CxF5ZvoXa6Cz6IcX3VyRHxMPRXYbv4PADxko3dwPF-I

我创建的一对旧代码的示例:

  • 验证者: 1jp6ku6-16xxjfi-1uteidc-9gjfso-1mcc0wn-tju0lh-tr2d8k-1auq4zk
  • 挑战: SRvuz5GW2HhXzHs6b3O_wzJq4sWN0W2ma96QBx_Z77s

然后我收到来自 API 的回复,说“code_verifier 不正确”。我在这里做错了什么?

javascript oauth spotify reactjs pkce

2
推荐指数
1
解决办法
2152
查看次数

如何标记在下一版本中已过时的方法?

是否有类似Obsolete或 的属性Deprecated指示某个方法在下一版本的 C# API 中已过时或已弃用?否则,是否有一个标准来表明这一点,例如将其添加到方法文档的注释中?

c# attributes warnings deprecated obsolete

1
推荐指数
1
解决办法
1312
查看次数