@yukiakai/actions-git 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/public.d.ts +1 -1
- package/dist/public.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,10 +51,9 @@ await repository.wipe(['.']);
|
|
|
51
51
|
|
|
52
52
|
await repository.add(['dist']);
|
|
53
53
|
|
|
54
|
-
await repository.commit('deploy: update documentation');
|
|
55
54
|
|
|
56
55
|
if (await repository.hasStagedChanges()) {
|
|
57
|
-
|
|
56
|
+
await repository.commit('deploy: update documentation');
|
|
58
57
|
await repository.push();
|
|
59
58
|
}
|
|
60
59
|
```
|
|
@@ -213,11 +212,12 @@ await repository.wipe(['.']);
|
|
|
213
212
|
|
|
214
213
|
await repository.add(['dist']);
|
|
215
214
|
|
|
216
|
-
await repository.commit('deploy');
|
|
217
215
|
if (!await repository.hasStagedChanges()) {
|
|
218
216
|
return;
|
|
219
217
|
}
|
|
220
218
|
|
|
219
|
+
await repository.commit('deploy');
|
|
220
|
+
|
|
221
221
|
await repository.push();
|
|
222
222
|
```
|
|
223
223
|
|
package/dist/public.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ declare class GitRepository {
|
|
|
12
12
|
private options;
|
|
13
13
|
constructor(options: GitRepositoryOptions);
|
|
14
14
|
private execute;
|
|
15
|
-
private
|
|
15
|
+
private executeInspectable;
|
|
16
16
|
wipe(pattern: string[]): Promise<void>;
|
|
17
17
|
setupIdentity(identity: GitIdentity): Promise<void>;
|
|
18
18
|
checkout(branch: string): Promise<void>;
|
package/dist/public.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{exec as m}from"@actions/exec";async
|
|
2
|
-
`))}}};import
|
|
1
|
+
import{exec as m}from"@actions/exec";var s=class{static async execute(t){let r=await m("git",[...t.args],{cwd:t.workingDirectory})}static async inspect(t){return{exitCode:await m("git",[...t.args],{cwd:t.workingDirectory,ignoreReturnCode:!0})}}};var n=class{constructor(t){this.options=t}execute(t){return s.execute({workingDirectory:this.options.workingDirectory,args:t})}executeInspectable(t){return s.inspect({workingDirectory:this.options.workingDirectory,args:t})}async wipe(t){await this.execute(["rm","-r","-f","--ignore-unmatch",...t]),await this.execute(["clean","-fdx","--",...t])}async setupIdentity(t){await this.execute(["config","user.name",t.name]),await this.execute(["config","user.email",t.email])}async checkout(t){await this.execute(["checkout",t])}async checkoutOrphan(t){await this.execute(["checkout","--orphan",t])}async pull(){await this.execute(["pull"])}async pullRebase(t){await this.execute(["pull","--rebase","origin",t])}async commit(t){await this.execute(["commit","-m",t])}async add(t){await this.execute(["add",...t])}async push(){await this.execute(["push","--set-upstream","origin","HEAD"])}async hasStagedChanges(){let t=await this.executeInspectable(["diff","--cached","--quiet"]);if(t.exitCode===0)return!1;if(t.exitCode===1)return!0;throw new Error(`git diff failed with exit code ${t.exitCode}`)}async hasLocalBranch(t){let r=await this.executeInspectable(["show-ref","--verify","--quiet",`refs/heads/${t}`]);if(r.exitCode===0)return!0;if(r.exitCode===1)return!1;throw new Error(`Failed to resolve local branch "${t}"`)}};var c=class{constructor(t){this.git=t}async initialize(t){if(await this.git.hasLocalBranch(t)){await this.git.checkout(t);return}await this.git.checkoutOrphan(t),await this.git.wipe(["."])}};var p=class{constructor(t){this.options=t}execInspectable(t){return s.inspect({workingDirectory:void 0,args:t})}async exists(t){let r=await this.execInspectable(["ls-remote","--exit-code","--heads",this.options.repositoryUrl,t]);switch(r.exitCode){case 0:return!0;case 2:return!1;default:throw new Error([`Failed to check remote branch "${t}"`,`Repository: ${this.options.repositoryUrl}`,`Exit code: ${r.exitCode}`].join(`
|
|
2
|
+
`))}}};import h from"path";var y=class{constructor(t){this.options=t}execute(t){return s.execute({workingDirectory:h.dirname(this.options.destinationDirectory),args:t})}async clone(){await this.execute(["clone",this.options.repositoryUrl,this.options.destinationDirectory])}async cloneAtBranch(t){await this.execute(["clone","--depth=1","--branch",t,this.options.repositoryUrl,this.options.destinationDirectory])}};var u=class{static build(t){let{token:r,repository:a}=t;return`https://x-access-token:${r}@github.com/${a}.git`}};async function d(e){let t=u.build({repository:e.repository,token:e.token}),r=new p({repositoryUrl:t}),a=new y({repositoryUrl:t,destinationDirectory:e.directory});await r.exists(e.branch)?await a.cloneAtBranch(e.branch):await a.clone();let l=new n({workingDirectory:e.directory});return await new c(l).initialize(e.branch),await l.setupIdentity(e.identity),l}var x={name:"github-actions[bot]",email:"github-actions[bot]@users.noreply.github.com"};export{x as GITHUB_ACTIONS_IDENTITY,n as GitRepository,d as prepareGitRepository};
|