Skip to content

Commit ce9034e

Browse files
authored
[fix]: Removes file in a deleted branch from state
2 parents f9ae9b4 + 9c9aaad commit ce9034e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

github/resource_github_repository_file.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,10 @@ func resourceGithubRepositoryFileRead(d *schema.ResourceData, meta interface{})
238238
if branch, ok := d.GetOk("branch"); ok {
239239
log.Printf("[DEBUG] Using explicitly set branch: %s", branch.(string))
240240
if err := checkRepositoryBranchExists(client, owner, repo, branch.(string)); err != nil {
241-
return err
241+
log.Printf("[INFO] Removing repository path %s/%s/%s from state because the branch no longer exists in GitHub",
242+
owner, repo, file)
243+
d.SetId("")
244+
return nil
242245
}
243246
opts.Ref = branch.(string)
244247
}

0 commit comments

Comments
 (0)