Skip to content

Commit

Permalink
[fix]: Removes file in a deleted branch from state
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfloyd authored Oct 11, 2023
2 parents f9ae9b4 + 9c9aaad commit ce9034e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion github/resource_github_repository_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ func resourceGithubRepositoryFileRead(d *schema.ResourceData, meta interface{})
if branch, ok := d.GetOk("branch"); ok {
log.Printf("[DEBUG] Using explicitly set branch: %s", branch.(string))
if err := checkRepositoryBranchExists(client, owner, repo, branch.(string)); err != nil {
return err
log.Printf("[INFO] Removing repository path %s/%s/%s from state because the branch no longer exists in GitHub",
owner, repo, file)
d.SetId("")
return nil
}
opts.Ref = branch.(string)
}
Expand Down

0 comments on commit ce9034e

Please sign in to comment.